Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace records
- {
- record class Automobile(string Marca, string Modello);
- record struct ClienteRecordStruct(string Cognome, string Nome);
- struct ClienteStruct{
- public ClienteStruct(string cognome, string nome)
- {
- Cognome = cognome;
- Nome = nome;
- }
- public string Cognome { get; set; }
- public string Nome { get; set; }
- }
- internal class Program
- {
- static void Main(string[] args)
- {
- ClienteStruct c1Struct = new ("De'Paperoni", "Paperon");
- ClienteStruct c2Struct = new ("De'Paperoni", "Paperon");
- c1Struct.Cognome = "De Paperoni";
- ClienteRecordStruct c1rs = new ClienteRecordStruct("De'Paperoni", "Paperon");
- ClienteRecordStruct c2rs = new ClienteRecordStruct("De'Paperoni", "Paperon");
- c1rs.Cognome = "sdfsd";
- //Console.WriteLine(c1Struct == c2Struct);
- Console.WriteLine(c1rs == c2rs);
- Console.WriteLine(c1rs != c2rs);
- //(string cognome, string nome) = c1Struct;
- var (cognome, nome) = c1rs;
- Console.WriteLine($"{cognome} {nome}");
- //Automobile auto1 = new Automobile("Fiat", "500");
- //Automobile auto2 = new Automobile("Fiat", "500");
- //Console.WriteLine(auto1 == auto2); //true
- ////auto1.Marca = "Mercedes"; NO, immutable!
- //Console.WriteLine(auto1.ToString());
- //Automobile auto3 = auto1 with { };
- //auto3 = auto3 with { Marca = "Honda" };
- //Console.WriteLine($"{auto1.Marca} {auto3.Marca}");
- //var (marca, modello) = auto3;
- //Console.WriteLine($"{marca}, {modello}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement