Found 26504 Articles for Server Side Programming

C# Object.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

304 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

361 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

961 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

C++ Program to implement standard error of mean

Ayush Gupta
Updated on 03-Dec-2019 11:25:42

282 Views

In this tutorial, we will be discussing a program to implement standard error of mean.Standard error of mean is the estimation of sample mean dispersion from population mean. Then it is used to estimate the approximate confidence intervals for the mean.Example#include using namespace std; //calculating sample 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[], int n){    float sum = 0;    for (int i = ... Read More

C++ program to implement Run Length Encoding using Linked Lists

Ayush Gupta
Updated on 10-Jul-2020 05:52:47

303 Views

In this tutorial, we will be discussing a program to implement Run Length Encoding using Linked Lists.For this we will be given with a linked list. OUr task is too encode the elements of the Linked List using Run Length Encoding.For example, if the elements of the linked list are “a->a->a->a->a” then in run length encoding they will be replaced by “a → 5”.Example#include using namespace std; //structuring linked list node struct Node {    char data;    struct Node* next; }; //creating a new node Node* newNode(char data){    Node* temp = new Node;    temp->data = data; ... Read More

C++ program to implement standard deviation of grouped data

Ayush Gupta
Updated on 03-Dec-2019 10:36:51

370 Views

In this tutorial, we will be discussing a program to implement standard deviation of grouped data.For this we will be given with class interval and frequency of the class. Our task is to find the standard deviation of the grouped data.Example#include using namespace std; //finding mean of grouped data float calc_mean(float mid[], int freq[], int n){    float sum = 0, freqSum = 0;    for (int i = 0; i < n; i++) {       sum = sum + mid[i] * freq[i];       freqSum = freqSum + freq[i];    }    return sum / ... Read More

Advertisements