This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| using System; | |
| using System.Collections.Generic; | |
| using System.IO; | |
| using System.Runtime.Serialization.Formatters.Binary; | |
| */ | |
| [Serializable()] | |
| public class Lizard | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Lizard | |
| { | |
| public string Type { get; set;} | |
| public int Number {get; set;} | |
| public bool Health {get; set;} | |
| public Lizard(string t, int n, bool h) | |
| { | |
| Type = t; | |
| Number = n; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //using System; | |
| //using System.Collections.Generic; | |
| //using System.Linq | |
| // | |
| class Program { | |
| static void Main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //using System; | |
| //using System.Collections.Generic; | |
| //using System.Linq | |
| // | |
| class Program { | |
| static void Main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //using System; | |
| //using System.Collections.Generic; | |
| //using System.Linq | |
| // | |
| class Program { | |
| static void Main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //using System; | |
| //using System.Collections.Generic; | |
| //using System.Linq | |
| //Concats two lists together, robot arms and robot legs into one list, 'resultlist' | |
| class Program { | |
| static void Main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //using System; | |
| //using System.Collections.Generic; | |
| //C# program that initializes Object Lists. | |
| //Robot has two properties, a ID and a name. | |
| //These | |
| class Robot //Used in lists .. (remember this are object Properties so it is UPPER case.) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // E.g., a strongly typed object versus using an anonymous type. | |
| //A1. As a traditional strongly typed class and instance of that class. | |
| public class Book | |
| { | |
| public int BookID { get; set; } | |
| public string BookName { get; set; } | |
| public string AuthorName { get; set; } | |
| public string ISBN { get; set; } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*This is a demo of anonymous type "request" that uses standalone Properties | |
| AND a Property which is a collection type, "Settings". | |
| Also demo'd is a foreach statement, for iterating through a Anonymous Type's collection Property. | |
| */ | |
| class Program { | |
| static void Main() | |
| { | |
| //Anonymous Object that also a list object as a property... Has a list object as a property. | |
| var request = new { Id = 1, UserId = 1, Settings = new List<IdValuePair>() { new IdValuePair { Id = 5, Value = "5" } } }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Simple, Anonymou type | |
| //lp- C# Program | |
| class Program { | |
| static void Main() | |
| { | |
| var v = new { Amount = 108, Message = "Hello" }; | |
| Console.WriteLine(v); |