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 232 views
232 views asked Dec 21, 2016 by avibootz
1 answer 279 views
1 answer 213 views
213 views asked Apr 25, 2017 by avibootz
1 answer 283 views
1 answer 215 views
215 views asked Jun 21, 2024 by avibootz
...