|
|
|
|
|
by mariusmg
4419 days ago
|
|
As much as i like C#, static typed languages are inadequate when using them in shell. You really don't want to type all that. Powershell has access to the BCL and can do all that with a nicer syntax when using it in the shell. |
|
// This an array of integers.
var x = new[]{1, 2, 3};
// This is a list of integers.
var y = x.ToList();
// This is an anonymous type.
var pet = new { Age = 10, Name = "Fluffy" };
Zero type names there. Not all types can be inferred by literals though, most annoyingly dictionaries:
var myDict = new Dictionary<string, string>{ { "test", "test" }, { "test2", "test2" } };
although I'm sure that could also have been created without typing out the name if you really wanted.