C# String ToUpperInvariant Method

AmitDiwan
Updated on 03-Dec-2019 12:31:04

1K+ Views

The String.ToUpperInvariant() method in C# is used to return a copy of this String object converted to uppercase using the casing rules of the invariant culture.SyntaxThe syntax is as follows -public string ToUpperInvariant ();ExampleLet us now see an example - Live Demousing System; using System.Text; public class Demo {    public static void Main(String[] args) {       string str1 = "one";       string str2 = "TWO";       string str3 = "ThrEE";       Console.WriteLine("String 1 = "+str1);       Console.WriteLine("String1 ToUpperInvariant = "+str1.ToUpperInvariant());       Console.WriteLine("String 2 = "+str2);       ... Read More

C# String ToLowerInvariant Method

AmitDiwan
Updated on 03-Dec-2019 12:18:20

1K+ Views

The String.ToLowerInvariant() method in C# is used to return a copy of this String object converted to lowercase using the casing rules of the invariant culture.SyntaxThe syntax is as follows -public string ToLowerInvariant ();ExampleLet us now see an example - Live Demousing System; using System.Text; public class Demo {    public static void Main(String[] args) {       string str1 = "Pink Floyd";       string str2 = "Ariana";       Console.WriteLine("String 1 = "+str1);       Console.WriteLine("String1 ToLowerInvariant = "+str1.ToLowerInvariant());       Console.WriteLine("String 2 = "+str2);       Console.WriteLine("String2 ToLowerInvariant = "+str2.ToLowerInvariant());     ... Read More

TimeSpan.FromTicks Method in C#

AmitDiwan
Updated on 03-Dec-2019 12:14:14

376 Views

The TimeSpan.FromTicks() method in C# is used to return a TimeSpan that represents a specified time, where the specification is in units of ticks.SyntaxThe syntax is as follows -public static TimeSpan FromTicks (long val);Above, the parameter val is the number of ticks that represent a time.ExampleLet us now see an example - Live Demousing System; public class Demo {    public static void Main() {       TimeSpan span1 = TimeSpan.FromTicks(18768768);       TimeSpan span2 = new TimeSpan(-9, 45, 50);       TimeSpan span3 = TimeSpan.FromHours(5);       TimeSpan span4 = TimeSpan.FromMilliseconds(10000);       TimeSpan span5 ... Read More

C# GetHashCode Method with Examples

AmitDiwan
Updated on 03-Dec-2019 12:10:56

1K+ Views

The Object.GetHashCode() method in C# is used to serve as the default hash function.Syntaxpublic virtual int GetHashCode ();ExampleLet us now see an example - Live Demousing System; public class Demo {    public static void Main() {       Object ob = new Object();       String str = "Jim";       Type type1 = ob.GetType();       Type type2 = str.GetType();       Console.WriteLine("Hash Code = "+type1.GetHashCode());       Console.WriteLine("Hash Code = "+type2.GetHashCode());    } }OutputHash Code =30015890 Hash Code =21083178ExampleLet us now see another example:using System; public struct Value {    private int v1;    private int ... Read More

C# IsNullOrWhitespace Method

AmitDiwan
Updated on 03-Dec-2019 12:06:56

318 Views

The IsNullOrWhiteSpace() method in C# is used to indicate whether a specified string is null, empty, or consists only of white-space characters.Syntaxpublic static bool IsNullOrWhiteSpace (string val);Above, the parameter val is the string to test. Let us now see an example −ExampleLet us now see an example: Live Demousing System; public class Demo {    public static void Main() {       string str1 = null;       string str2 = String.Empty;       Console.WriteLine("Is string1 null or whitespace? = "+String.IsNullOrWhiteSpace(str1));       Console.WriteLine("Is string2 null or whitespace? = "+String.IsNullOrWhiteSpace(str2));    } }OutputThis will produce the following ... Read More

C# BitConverter.ToUInt16 Method

AmitDiwan
Updated on 03-Dec-2019 12:03:46

370 Views

The BitConverter.ToUInt16() method in C# is used to return a 16-bit unsigned integer converted from two bytes at a specified position in a byte array.Syntaxpublic static ushort ToUInt16 (byte[] val, int begnIndex);Above, val is the byte array, whereas begnIndex is the beginning position within val.ExampleLet us now see an example - Live Demousing System; public class Demo {    public static void Main() {       byte[] arr = { 10, 20, 30, 40, 50};       int count = arr.Length;       Console.Write("Byte Array... ");       for (int i = 0; i < count; i++) ... Read More

TimeSpan.FromSeconds Method in C#

AmitDiwan
Updated on 03-Dec-2019 11:57:05

4K+ Views

The TimeSpan.FromSeconds() method in C# is used to return a TimeSpan that represents a specified number of seconds, where the specification is accurate to the nearest millisecond.SyntaxThe syntax is as follows -public static TimeSpan FromSeconds (double val);Above, the parameter val is the number of seconds, accurate to the nearest millisecond.ExampleLet us now see an example - Live Demousing System; public class Demo {    public static void Main() {       TimeSpan span1 = TimeSpan.FromSeconds(0.6768788);       TimeSpan span2 = new TimeSpan(25, 15, 45);       TimeSpan span3 = TimeSpan.FromHours(.4788);       TimeSpan span4 = TimeSpan.FromMilliseconds(0.8787);   ... Read More

TimeSpan FromMinutes Method in C#

AmitDiwan
Updated on 03-Dec-2019 11:51:18

2K+ Views

The TimeSpan.FromMinutes() method in C# is used to return a TimeSpan that represents a specified number of minutes, where the specification is accurate to the nearest millisecond.Syntaxpublic static TimeSpan FromMinutes (double val);Above, the value val is the number of minutes, accurate to the nearest millisecond.Example Live Demousing System; public class Demo {    public static void Main() {       TimeSpan span1 = TimeSpan.FromHours(0.78787);       TimeSpan span2 = new TimeSpan(10, 30, 40);       TimeSpan span3 = TimeSpan.FromHours(5);       TimeSpan span4 = TimeSpan.FromMilliseconds(1);       TimeSpan span5 = TimeSpan.FromMinutes(100);       Console.WriteLine("TimeSpan1 = ... Read More

C# String Contains Method

AmitDiwan
Updated on 03-Dec-2019 11:38:59

8K+ Views

The String.Contains() method in C# is used to return a value indicating whether a specified substring occurs within this string.Syntaxpublic bool Contains (string val);Above, val is the string to search for.Example Live Demousing System; public class Demo {    public static void Main(String[] args) {       string str1 = "Akon";       string str2 = "Ak";       Console.WriteLine("String 1 = "+str1);       Console.WriteLine("HashCode of String 1 = "+str1.GetHashCode());       Console.WriteLine("String 2 = "+str2);       Console.WriteLine("HashCode of String 2 = "+str2.GetHashCode());       Console.WriteLine("String 1 is equal to String 2: ... Read More

C++ Program to Implement T-Test

Ayush Gupta
Updated on 03-Dec-2019 11:26:46

987 Views

In this tutorial, we will be discussing a program to implement t-test.The t-test of the student’s T test is used to compare two means and tell if both of them are similar or different. Along with this, t-test also helps to determine how large the differences are to know the reason for the change.Example#include using namespace std; //calculating mean float calc_mean(float arr[], int n){    float sum = 0;    for (int i = 0; i < n; i++)       sum = sum + arr[i];    return sum / n; } //calculating standard deviation float calc_deviation(float arr[], ... Read More

Advertisements