Found 2628 Articles for Csharp

Type.GetDefaultMembers() Method in C#

AmitDiwan
Updated on 04-Nov-2019 10:37:17

52 Views

The Type.GetDefaultMembers() method in C# is used to search for the members defined for the current Type whose DefaultMemberAttribute is set.Syntaxpublic virtual System.Reflection.MemberInfo[] GetDefaultMembers ();Let us now see an example to implement the Type.GetDefaultMembers() method −Exampleusing System; using System.Reflection; [DefaultMemberAttribute("subject")] public class Demo {    public static void Main(){       Type t = typeof(Demo);       MemberInfo[] member = t.GetDefaultMembers();       if (member.Length != 0){          for (int i = 0; i < member.Length; i++)          Console.WriteLine("{0}", member[i]);       }       else {     ... Read More

Type.GetArrayRank() Method in C#

AmitDiwan
Updated on 04-Nov-2019 10:35:11

61 Views

The Type.GetArrayRank() method in C# gets the number of dimensions in an array.Syntaxpublic virtual int GetArrayRank ();Let us now see an example to implement the Type.GetArrayRank() method −Exampleusing System; public class Demo {    public static void Main(string[] args) {       Type type = typeof(int[, , ]);       int arrRank = type.GetArrayRank();       Console.WriteLine("Array Rank = {0}", arrRank);    } }OutputThis will produce the following output −Array Rank = 3Let us now see another example to implement the Type.GetArrayRank() method −Exampleusing System; public class Demo {    public static void Main(string[] args) {   ... Read More

Type.Equals() Method in C#

AmitDiwan
Updated on 04-Nov-2019 10:31:27

723 Views

The Type.Equals() method in C# determines if the underlying system type of the current Type is the same as the underlying system type of the specified Object or Type.Syntaxpublic virtual bool Equals (Type o); public override bool Equals (object o);Above, the parameters are the object whose underlying system type is to be compared with the underlying system type of the current Type.Let us now see an example to implement the Type.Equals() method −using System; public class Demo {    public static void Main(string[] args) {       Type val1 = typeof(System.UInt16);       Type val2 = typeof(System.Int32);   ... Read More

Tuple Class in C#

AmitDiwan
Updated on 04-Nov-2019 10:29:26

57 Views

The Tuple class represents a 7-tuple, which is called septet. A tuple is a data structure that has a sequence of elements.It is used in −Easier access to a data set.Easier manipulation of a data set.To represent a single set of data.To return multiple values from a methodTo pass multiple values to a methodIt has seven properties −Item1− Get the value of the current Tuple object's first component.Item2− Get the value of the current Tuple object's second component.Item3− Get the value of the current Tuple object's third component.Item4− Get the value of the current Tupleobject's fourth component.Item5− Get the value ... Read More

Tuple Class in C#

AmitDiwan
Updated on 04-Nov-2019 10:26:19

56 Views

The Tuple class represents a 6-tuple. A tuple is a data structure that has sequence of elements.It is used in −Easier access to a data set.Easier manipulation of a data set.To represent a single set of data.To return multiple values from a methodTo pass multiple values to a methodIt has six properties −Item1− Get the value of the current Tuple object's first component.Item2− Get the value of the current Tuple object's second component.Item3− Get the value of the current Tuple object's third component.Item4− Get the value of the current Tuple object's fourth component.Item5− Get the value of the current Tuple ... Read More

Tuple Class in C#

AmitDiwan
Updated on 04-Nov-2019 10:14:47

116 Views

The Tuple class represents a 5-tuple, which is called quintuple. A tuple is a data structure that has a sequence of elements.It is used in −Easier access to a data set.Easier manipulation of a data set.To represent a single set of data.To return multiple values from a methodTo pass multiple values to a methodIt has five properties −Item1− Get the value of the current Tuple object's first component.Item2− Get the value of the current Tuple object's second component.Item3− Get the value of the current Tuple object's third component.Item4− Get the value of the current Tuple object's fourth component.Item5− Get the ... Read More

Math.Floor() Method in C#

AmitDiwan
Updated on 04-Nov-2019 10:08:50

3K+ Views

The Math.Floor() method in C# is used to return the largest integral value less than or equal to the specified number.Syntaxpublic static decimal Floor (decimal val); public static double Floor (double val)For the first syntax above, the value val is the decimal number, whereas Val in the second syntax is the double number.Let us now see an example to implement Math.Floor() method −Exampleusing System; public class Demo {    public static void Main(){       decimal val1 = 7.10M;       decimal val2 = -79.89M;       Console.WriteLine("Result = " + Math.Floor(val1));       Console.WriteLine("Result = ... Read More

Math.Exp() Method in C#

AmitDiwan
Updated on 04-Nov-2019 10:06:36

139 Views

The Math.Exp() method in C# is used to return e raised to the specified power.Syntaxpublic static double Exp (double val);Here, Val is the power.If Val equals NaN or PositiveInfinity, that value is returned. However, if d equals NegativeInfinity, 0 is returned.Let us now see an example to implement Math.Exp() method −Exampleusing System; public class Demo {    public static void Main(){       Console.WriteLine(Math.Exp(0.0));       Console.WriteLine(Math.Exp(Double.PositiveInfinity));       Console.WriteLine(Math.Exp(Double.NegativeInfinity));    } }OutputThis will produce the following output −1 ∞ 0Let us see another example to implement Math.Exp() method −Exampleusing System; public class Demo {    public ... Read More

Math.DivRem() Method in C#

AmitDiwan
Updated on 04-Nov-2019 10:03:47

2K+ Views

The Math.DivRem() method in C# is used to divide and calculate the quotient of two numbers and also returns the remainder in an output parameter.Syntaxpublic static int DivRem (int dividend, int divisor, out int remainder); public static long DivRem (long dividend, long divisor, long remainder);Let us now see an example to implement Math.DivRem() method −Exampleusing System; public class Demo {    public static void Main(){       int dividend = 30;       int divisor = 7;       int remainder;       int quotient = Math.DivRem(dividend, divisor, out remainder);       Console.WriteLine("Quotient = "+quotient); ... Read More

Char.IsWhiteSpace() Method in C#

AmitDiwan
Updated on 04-Nov-2019 09:59:10

282 Views

The Char.IsWhiteSpace() method in C# is used to indicate whether the specified Unicode character is white space.Syntaxpublic static bool IsWhiteSpace (char ch);Above, the parameter ch is the Unicode character to evaluate.Let us now see an example to implement the Char.IsWhiteSpace() method −Exampleusing System; public class Demo {    public static void Main(){       bool res;       char val = ' ';       Console.WriteLine("Value = "+val);       res = Char.IsWhiteSpace(val);       Console.WriteLine("Is the value whitespace? = "+res);    } }OutputThis will produce the following output −Value = Is the value whitespace? ... Read More

Advertisements