summaryrefslogtreecommitdiffhomepage
path: root/csharp.html.markdown
diff options
context:
space:
mode:
authorMelvyn <melvyn.laily@gmail.com>2013-09-21 15:27:55 -0400
committerMelvyn <melvyn.laily@gmail.com>2013-09-21 15:27:55 -0400
commita2b14fcedfaa01d6dea7d7682b82fc5ddae9b84d (patch)
tree60b3610cc214ee05170f75e73e92d64d8236ea1d /csharp.html.markdown
parent81c0480780a600ef27071285e002e8ea78dc727c (diff)
mentioned strings immutability and added details about var keyword (C#)
Diffstat (limited to 'csharp.html.markdown')
-rw-r--r--csharp.html.markdown5
1 files changed, 5 insertions, 0 deletions
diff --git a/csharp.html.markdown b/csharp.html.markdown
index 16e3749e..c6394974 100644
--- a/csharp.html.markdown
+++ b/csharp.html.markdown
@@ -111,6 +111,9 @@ namespace Learning
// a string is a reference type. That is, you can set it to null
string fooString = "My string is here!";
Console.WriteLine(fooString);
+ // You can access each character of the string with an indexer:
+ char charFromString = fooString[1]; // 'y'
+ // Strings are immutable: you can't do fooString[1] = 'X';
// formatting
string fooFs = string.Format("Check Check, {0} {1}, {0} {1:0.0}", 1, 2);
@@ -165,6 +168,8 @@ namespace Learning
Console.WriteLine("Not nullable variable: " + notNullable);
// Var - compiler will choose the most appropriate type based on value
+ // Please not that this does not remove type safety.
+ // In this case, the type of fooImplicit is known to be a bool at compile time
var fooImplicit = true;
///////////////////////////////////////////////////