How to use properties in struct with C#

1 Answer

0 votes
using System;

struct Student {
    public int id;
    public string name;
}

class Program
{
    static void Main(string[] args) {
      Student s;
      
      s.id = 73462;
      s.name = "Emma";
      
      Console.WriteLine(s.id);
      Console.WriteLine(s.name);
    }
}

 
 
/*
run:
 
73462
Emma
 
*/

 



answered Dec 15, 2020 by avibootz

Related questions

1 answer 147 views
147 views asked Dec 21, 2016 by avibootz
1 answer 182 views
1 answer 126 views
126 views asked Apr 25, 2017 by avibootz
1 answer 201 views
1 answer 105 views
105 views asked Jun 21, 2024 by avibootz
1 answer 153 views
153 views asked Dec 15, 2020 by avibootz
1 answer 131 views
...