diff options
author | 2011-05-12 09:56:11 +0530 | |
---|---|---|
committer | 2011-05-12 09:56:11 +0530 | |
commit | 746c28cd03e8840e8525352ff2aebcfeb76ca2a1 (patch) | |
tree | f09450daf5427605cdfe60d42bc7aac78f422278 | |
parent | a1affe2114ae22816cf72d14fb4ae357a64fe7f2 (diff) |
added examples of generics and string support needed by Poirot
-rw-r--r-- | BCT/Samples/Generics/GenericsExample.cs | 20 | ||||
-rw-r--r-- | BCT/Samples/Strings/StringsExample.cs | 20 |
2 files changed, 40 insertions, 0 deletions
diff --git a/BCT/Samples/Generics/GenericsExample.cs b/BCT/Samples/Generics/GenericsExample.cs new file mode 100644 index 00000000..c7016ceb --- /dev/null +++ b/BCT/Samples/Generics/GenericsExample.cs @@ -0,0 +1,20 @@ +using System;
+using System.Collections.Generic;
+using System.Diagnostics.Contracts;
+using System.Linq;
+using System.Text;
+
+/* Simple example of generics/dictionary support needed by Poirot */
+class GenericsExample
+{
+ public static void Main()
+ {
+ Dictionary<String, String> dict = new Dictionary<String, String>();
+ dict["foo"] = "bar";
+ Contract.Assert(dict.ContainsKey("foo"));
+ Contract.Assert(dict.ContainsValue("bar"));
+ Contract.Assert(dict["foo"] == "bar");
+ dict.Remove("foo");
+ Contract.Assert(dict["foo"] == "bar"); // should fail
+ }
+}
\ No newline at end of file diff --git a/BCT/Samples/Strings/StringsExample.cs b/BCT/Samples/Strings/StringsExample.cs new file mode 100644 index 00000000..a04fc9a0 --- /dev/null +++ b/BCT/Samples/Strings/StringsExample.cs @@ -0,0 +1,20 @@ +using System;
+using System.Collections.Generic;
+using System.Diagnostics.Contracts;
+using System.Linq;
+using System.Text;
+
+/* Example of string functionality needed by Poirot: concatenation and equality */
+class StringsExample
+{
+ public static void Main()
+ {
+ string foo = "delicious";
+ string bar = "cake";
+ Contract.Assert(!foo.Equals(bar));
+ string foo_bar = foo + bar;
+ Contract.Assert(foo_bar.Equals("deliciouscake"));
+ string delish = "delicious";
+ Contract.Assert(foo.Equals(delish));
+ }
+}
\ No newline at end of file |