Programming Articles - Page 2325 of 3366

Type.GetTypeCode() Method in C#

AmitDiwan
Updated on 11-Nov-2019 07:32:38

236 Views

The Type.GetTypeCode() method in C# is used to get the underlying type code of the specified Type.SyntaxFollowing is the syntax −public static TypeCode GetTypeCode (Type type);Above, the type parameter is the type whose underlying type code to get.ExampleLet us now see an example to implement the Type.GetTypeCode() method −using System; public class Demo {    public static void Main(){       Type type1 = typeof(double);       TypeCode type2 = Type.GetTypeCode(type1);       Console.WriteLine("TypeCode = "+type2);    } }OutputThis will produce the following output −TypeCode = DoubleExampleLet us now see another example to implement the Type.GetTypeCode() method ... Read More

Type.GetTypeArray() Method in C#

AmitDiwan
Updated on 11-Nov-2019 07:31:22

89 Views

The Type.GetTypeArray() method in C# is used to get the types of the objects in the specified array.SyntaxFollowing is the syntax −public static Type[] GetTypeArray (object[] args);The arg argument is an array of objects whose types to determine.ExampleLet us now see an example to implement the Type.GetTypeArray() method −using System; using System.Reflection; public class Demo {    public static void Main(){       Object[] obj = new Object[5];       obj[0] = 10.20;       obj[1] = 20;       obj[2] = 30;       obj[3] = 40;       obj[4] = "tom";   ... Read More

Type.GetProperties() Method in C#

AmitDiwan
Updated on 11-Nov-2019 07:29:46

472 Views

The Type.GetProperties() method in C# is used to get the properties of the current Type.SyntaxFollowing is the syntax −public System.Reflection.PropertyInfo[] GetProperties (); public abstract System.Reflection.PropertyInfo[] GetProperties (System.Reflection.BindingFlags bindingAttr);Above, bindingAttr is a bitwise combination of the enumeration values that specify how the search is performed.Exampleusing System; using System.Reflection; public class Demo {    public static void Main(){       Type type = typeof(System.Type);       PropertyInfo[] info = type.GetProperties();       Console.WriteLine("Properties... ");       for (int i = 0; i < info.Length; i++)          Console.WriteLine(" {0}", info[i].ToString());    } }OutputThis will produce the ... Read More

Boolean.ToString() Method in C#

AmitDiwan
Updated on 11-Nov-2019 07:28:13

7K+ Views

The Boolean.ToString() method in C# converts the value of this instance to its equivalent string representation (either "True" or "False").SyntaxFollowing is the syntax −public override string ToString ();ExampleLet us now see an example to implement the Boolean.ToString() method −using System; public class Demo {    public static void Main(){       bool b = true;       string res = b.ToString();       Console.WriteLine("Return Value = "+res);    } }OutputThis will produce the following output −Return Value = TrueExampleLet us now see another example to implement the Boolean.ToString() method −using System; public class Demo {    public ... Read More

Boolean.Parse() Method in C#

AmitDiwan
Updated on 24-Apr-2020 11:11:22

1K+ Views

The Boolean.Parse() method in C# is used to convert the specified string representation of a logical value to its Boolean equivalent.SyntaxFollowing is the syntax −public static bool Parse (string val);Above, the parameter value is a string containing the value to convert.ExampleLet us now see an example to implement the Boolean.Parse() method −using System; public class Demo {    public static void Main(){       bool b;       b = bool.Parse("FALSE");       Console.WriteLine("After parsing = "+b);    } }OutputThis will produce the following output −After parsing = FalseExampleLet us see another example −using System; public class ... Read More

Boolean.Equals(Object) Method in C#

AmitDiwan
Updated on 11-Nov-2019 07:25:22

176 Views

The Boolean.Equals(Object) method in C# returns a value indicating whether this instance is equal to a specified object.SyntaxFollowing is the syntax −public override bool Equals (object ob);Above, ob is an object to compare to this instance.ExampleLet us now see an example to implement the Boolean.Equals(Object) method −using System; public class Demo {    public static void Main(){       bool val1 = true;       object val2 = 5/10;       if (val1.Equals(val2))          Console.WriteLine("Both are equal!");       else          Console.WriteLine("Both aren't equal!");    } }OutputThis will produce the following output −Both aren't equal!

Boolean.Equals(Boolean) Method in C#

AmitDiwan
Updated on 11-Nov-2019 07:23:45

468 Views

The Boolean.Equals(Boolean) method in C# returns a value indicating whether this instance is equal to a specified Boolean object.SyntaxFollowing is the syntax −public bool Equals (bool ob);Above, ob is a Boolean value to compare to this instance.ExampleLet us now see an example to implement the Boolean.Equals(Boolean) method −using System; public class Demo {    public static void Main(){       bool b1 = false;       bool b2 = true;       bool res = b1.Equals(b2);       if (res == true)          Console.Write("b1 equal to b2");       else     ... Read More

How to use @Until annotation using the Gson library in Java?

raja
Updated on 08-Jul-2020 12:01:11

364 Views

The @Until annotation can use with the setVersion() method of the GsonBuilder class. This annotation can apply to a field in java class and accepts float as an argument. This argument represents the version number in which the field has serialized. The @Until annotation can manage the versioning of JSON classes in web-services.Syntax@Documented @Retention(value=RUNTIME) @Target(value={FIELD, TYPE}) public @interface UntilExampleimport com.google.gson.annotations.Until; import com.google.gson.Gson; import com.google.gson.GsonBuilder; public class GsonUntilAnnotationTest {    public static void main(String[] args) {       Employee emp = new Employee();       emp.setEmployeeName("Adithya");       emp.setEmployeeId(115);       emp.setEmployeeTechnology("Python");       emp.setEmploeeAddress("Pune");       ... Read More

DateTimeOffset.AddMilliseconds() Method in C#

AmitDiwan
Updated on 11-Nov-2019 07:21:58

102 Views

The DateTimeOffset.AddMilliseconds() method in C# is used to return a new DateTimeOffset object that adds a specified number of milliseconds to the value of this instance.SyntaxFollowing is the syntax −public DateTimeOffset AddMilliseconds (double val);Above, Val are the milliseconds to be added. To subtract, set a negative value.ExampleLet us now see an example to implement the DateTimeOffset.AddMilliseconds() method −using System; public class Demo {    public static void Main() {       DateTimeOffset dateTimeOffset = new DateTimeOffset(2019, 08, 10, 4, 20, 10, new TimeSpan(-5, 0, 0));       Console.WriteLine("DateTimeOffset (before adding milliseconds) = {0}", dateTimeOffset);       DateTimeOffset ... Read More

DateTimeOffset.AddHours() Method in C#

AmitDiwan
Updated on 11-Nov-2019 07:13:13

289 Views

The DateTimeOffset.AddHours() method in C# is used to add a specified number of whole and fractional hours to the value of this instance.SyntaxFollowing is the syntax −public DateTimeOffset AddHours (double hrs);Above, hrs are the hours to be added. To subtract hours, include a negative value.ExampleLet us now see an example to implement the DateTimeOffset.AddHours() method −using System; public class Demo {    public static void Main() {       DateTimeOffset dateTimeOffset = new DateTimeOffset(2019, 10, 10, 3, 15, 0, new TimeSpan(-5, 0, 0));       Console.WriteLine("DateTimeOffset (before adding hours) = {0}", dateTimeOffset);       DateTimeOffset res = ... Read More

Advertisements