Use method to init struct member variables : Constructor : Struct C# Examples


C# Examples » Struct » Constructor »

 

Use method to init struct member variables









    
using  System;


public  struct  Simple  {

    public    int  i;
    private  string  s;
    

    public  void  init(  )  {
        i  =  10;
        s  =  "Hello";
    }
    
}



public  class  MainClass  {

    public  static  void  Main(  )  {

        Simple  simple  =  new  Simple();
    
        simple.init(  );
        
    }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Struct
» Constructor