summaryrefslogtreecommitdiff
path: root/reference
diff options
context:
space:
mode:
authorXavi Artigas <xavierartigas@yahoo.es>2018-12-31 17:36:21 +0100
committerXavi Artigas <xavierartigas@yahoo.es>2018-12-31 17:36:21 +0100
commite06157c1f625adc2fe7c1df79a0148308bf67e57 (patch)
tree98acbc78277d0c1c430112b33147d40350bf6b72 /reference
parenta7c5ff510ec94f4b00ebfcf91c911dc0d3fedbbb (diff)
efl-mono: Use new Eina.Value implicit conversions
Diffstat (limited to 'reference')
-rw-r--r--reference/csharp/eina/src/eina_value.cs37
1 files changed, 9 insertions, 28 deletions
diff --git a/reference/csharp/eina/src/eina_value.cs b/reference/csharp/eina/src/eina_value.cs
index c4765e4a..d718b6b5 100644
--- a/reference/csharp/eina/src/eina_value.cs
+++ b/reference/csharp/eina/src/eina_value.cs
@@ -13,13 +13,9 @@ public class Example
13{ 13{
14 static void ValueInt() 14 static void ValueInt()
15 { 15 {
16 int i;
17
18 // Setting up an integer value type 16 // Setting up an integer value type
19 var int_val = new Eina.Value(Eina.ValueType.Int32); 17 Eina.Value int_val = 123;
20 int_val.Set(123); 18 Console.WriteLine("int_val value is {0}", int_val);
21 int_val.Get(out i);
22 Console.WriteLine("int_val value is {0}", i);
23 19
24 // It can easily be converted to a string 20 // It can easily be converted to a string
25 string str = int_val.ToString(); 21 string str = int_val.ToString();
@@ -28,13 +24,9 @@ public class Example
28 24
29 static void ValueString() 25 static void ValueString()
30 { 26 {
31 string str;
32
33 // Setting up an string value type 27 // Setting up an string value type
34 var str_val = new Eina.Value(Eina.ValueType.String); 28 Eina.Value str_val = "My string";
35 str_val.Set("My string"); 29 Console.WriteLine("str_val value is \"{0}\"", str_val);
36 str_val.Get(out str);
37 Console.WriteLine("str_val value is \"{0}\"", str);
38 30
39 // To string should have the same content 31 // To string should have the same content
40 string newstr = str_val.ToString(); 32 string newstr = str_val.ToString();
@@ -43,27 +35,16 @@ public class Example
43 35
44 static void ValueConvert() 36 static void ValueConvert()
45 { 37 {
46 // Set up string and int types to convert between
47 var str_val = new Eina.Value(Eina.ValueType.String);
48 var int_val = new Eina.Value(Eina.ValueType.Int32);
49
50 // Convert from int to string: 38 // Convert from int to string:
51 int i1; 39 Eina.Value int_val = 123;
52 string str1; 40 Eina.Value str_val = new Eina.Value(Eina.ValueType.String);
53 int_val.Set(123);
54 int_val.Get(out i1);
55 int_val.ConvertTo(str_val); 41 int_val.ConvertTo(str_val);
56 str_val.Get(out str1); 42 Console.WriteLine("int_val was {0}, converted to string is \"{1}\"", int_val, str_val);
57 Console.WriteLine("int_val was {0}, converted to string is \"{1}\"", i1, str1);
58 43
59 // And the other way around! 44 // And the other way around!
60 int i2; 45 str_val = "33.000";
61 string str2;
62 str_val.Set("33");
63 str_val.Get(out str2);
64 str_val.ConvertTo(int_val); 46 str_val.ConvertTo(int_val);
65 int_val.Get(out i2); 47 Console.WriteLine("str_val was \"{0}\", converted to int is {1}", str_val, int_val);
66 Console.WriteLine("str_val was \"{0}\", converted to int is {1}", str2, i2);
67 } 48 }
68 49
69 public static void Main() 50 public static void Main()