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 158 views
158 views asked Dec 21, 2016 by avibootz
1 answer 190 views
1 answer 136 views
136 views asked Apr 25, 2017 by avibootz
1 answer 207 views
1 answer 115 views
115 views asked Jun 21, 2024 by avibootz
1 answer 165 views
165 views asked Dec 15, 2020 by avibootz
1 answer 143 views
...