Last active
December 15, 2015 11:39
-
-
Save btjake/5254652 to your computer and use it in GitHub Desktop.
Optional in C#
This file contains 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; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace OptionalParams | |
{ | |
public class CoolKidsClass | |
{ | |
List<int> numbers = new List<int>(); | |
public string text = ""; | |
public CoolKidsClass(string _text) | |
{ | |
text = _text; | |
for (int i = 0; i < 100; i++) | |
{ | |
numbers.Add(i); | |
} | |
} | |
} | |
} |
This file contains 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
instantiated in StaticMethod | |
instantiated in Main | |
This file contains 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; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Runtime.InteropServices; | |
namespace OptionalParams | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
StaticMethod(); | |
StaticMethod(new CoolKidsClass("instantiated in Main")); | |
Console.ReadKey(); | |
} | |
public static void StaticMethod(CoolKidsClass ckc = null) | |
{ | |
if (ckc == null) ckc = new CoolKidsClass("instantiated in StaticMethod"); | |
Console.WriteLine(ckc.text); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment