Chash Copy Method in Java

AmitDiwan
Updated on 03-Dec-2019 10:19:27

495 Views

The Copy() method in C# is used to create a new instance of String with the same value as a specified String.Syntaxpublic static string Copy (string s);Above, s is the string to copy.Example Live Demousing System; public class Demo {    public static void Main(string[] args) {       string s1 = "Amy";       string s2 = "Katie";       string s3 = String.Copy(s2);       Console.WriteLine("String1 = "+s1);       Console.WriteLine("String2 = "+s2);       Console.WriteLine("Are both the strings equal? = "+s1.Equals(s2));       Console.WriteLine("Are both the strings equal? = "+s2.Equals(s3));   ... Read More

C++ Program to Generate Random Alphabets

Ayush Gupta
Updated on 03-Dec-2019 10:17:22

906 Views

In this tutorial, we will be discussing a program to generate random alphabets.For this, we will have a fixed size of array/string and use the rand() function to generate a random string of alphabets.Example#include using namespace std; const int MAX = 26; //generating a string of random alphabets string gen_random(int n){    char alphabet[MAX] = {       'a', 'b', 'c', 'd', 'e', 'f', 'g',       'h', 'i', 'j', 'k', 'l', 'm', 'n',       'o', 'p', 'q', 'r', 's', 't', 'u',       'v', 'w', 'x', 'y', 'z'    };    string res ... Read More

C++ Program to Generate Captcha and Verify User

Ayush Gupta
Updated on 03-Dec-2019 10:13:06

829 Views

In this tutorial, we will be discussing a program to generate CAPTCHA and verify user.For this, we will provide the user with a random string and ask him to reenter the same string. Then it has to be checked if the given and the input string matches.The CAPTCHA should be completely random system generated consisting of a-z, AZ and 0-9.Example#include using namespace std; //checks if the strings are same bool check_string(string &captcha, string &user_captcha){    return captcha.compare(user_captcha) == 0; } //generates a random string as Captcha string gen_captcha(int n){    time_t t;    srand((unsigned)time(&t));    char *chrs = "abcdefghijklmnopqrstuvwxyzABCDEFGHI" "JKLMNOPQRSTUVWXYZ0123456789"; ... Read More

StringBuilder ToString Method in C#

AmitDiwan
Updated on 03-Dec-2019 09:57:10

2K+ Views

The StringBuilder.ToString() method in C# is used to convert the value of a StringBuilder to a String.SyntaxThe syntax is as follows −public override string ToString (); public string ToString (int begnIndex, int len);Above, the parameter begnIndex is the starting position of the substring in this instance, whereas len is the length of the substring.ExampleLet us now see an example − Live Demousing System; using System.Text; public class Demo{    public static void Main(){       StringBuilder strBuilder = new StringBuilder("Katie");       Console.WriteLine("String = "+strBuilder.ToString());       Console.WriteLine("StringBuilder capacity = "+strBuilder.Capacity);       Console.WriteLine("StringBuilder length = "+strBuilder.Length); ... Read More

Random Next Method in C#

AmitDiwan
Updated on 03-Dec-2019 09:54:27

3K+ Views

The Random.Next() method in C# is used to return a non-negative random integer.SyntaxThe syntax is as follows −public virtual int Next (); public virtual int Next (int maxVal);Above, the maxVal parameter is the exclusive upper bound of the random number to be generated.ExampleLet us now see an example − Live Demousing System; public class Demo {    public static void Main(){       Random r = new Random();       Console.WriteLine("Random numbers.....");       for (int i = 1; i

SortedDictionary Values Property in C#

AmitDiwan
Updated on 03-Dec-2019 09:52:19

186 Views

The SortedDictionary.Value property in C# is used to get a collection containing the values in the SortedDictionary.SyntaxThe syntax is as follows −public System.Collections.Generic.SortedDictionary.ValueCollection Values { get; }ExampleLet us now see an example − Live Demousing System; using System.Collections; using System.Collections.Generic; public class Demo {    public static void Main(){       SortedDictionarysortedDict = new SortedDictionary();       sortedDict.Add(1, "Ultrabook");       sortedDict.Add(2, "Alienware");       sortedDict.Add(3, "Notebook");       sortedDict.Add(4, "Connector");       sortedDict.Add(5, "Flash Drive");       sortedDict.Add(6, "SSD");       sortedDict.Add(7, "HDD");       sortedDict.Add(8, "Earphone");       Console.WriteLine("SortedDictionary ... Read More

Double.IsNegativeInfinity Method in C#

AmitDiwan
Updated on 03-Dec-2019 09:48:11

70 Views

The Double.IsNegativeInfinity() method in C# is used to return a value indicating whether the specified number evaluates to negative infinity.SyntaxThe syntax is as follows −public static bool IsNegativeInfinity (double val);Above, val is a double-precision floating-point number.ExampleLet us now see an example − Live Demousing System; public class Demo {    public static void Main(){       double d = 0.0/0;       Console.WriteLine("Double Value = "+d);       Console.WriteLine("HashCode of Double Value = "+d.GetHashCode());       TypeCode type = d.GetTypeCode();       Console.WriteLine("TypeCode of Double Value = "+type);       Console.WriteLine("Positive Infinity? = "+Double.IsInfinity(d));   ... Read More

Boolean getTypeCode Method in C# with Examples

AmitDiwan
Updated on 03-Dec-2019 09:46:18

87 Views

The Boolean.GetTypeCode() method in C# is used to return the type code for the Boolean value type.SyntaxThe syntax is as follows −public TypeCode GetTypeCode ();ExampleLet us now see an example − Live Demousing System; public class Demo {    public static void Main(String[] args){       string str = "JackSparrow!";       bool val = true;       char[] arr = { 'J', 'a'};       Console.WriteLine("String = "+str);       Console.WriteLine("String (after trim) = " + str.Trim(arr));       Console.WriteLine("String (Hashcode) = "+str.GetHashCode());       Console.WriteLine("Bool (Hashcode) = "+val.GetHashCode());       Console.WriteLine("Bool ... Read More

StringBuilder ensureCapacity Method in C#

AmitDiwan
Updated on 03-Dec-2019 09:43:35

157 Views

The StringBuilder.EnsureCapacity() method in C# is used to ensure that the capacity of this instance of StringBuilder is at least the specified value.SyntaxThe syntax is as follows −public int EnsureCapacity (int capacity);Above, the parameter capacity is the minimum capacity to ensure.ExampleLet us now see an example − Live Demousing System; using System.Text; public class Demo{    public static void Main(){       StringBuilder strBuilder = new StringBuilder("jhbjhb");       Console.WriteLine("String = "+strBuilder);       Console.WriteLine("StringBuilder capacity= "+strBuilder.Capacity);       strBuilder.EnsureCapacity(20);       Console.WriteLine("StringBuilder capacity= "+strBuilder.Capacity);       char[] arr = new char[5] {'a', 'b', 'c', ... Read More

Int64 ToString Method in C#

AmitDiwan
Updated on 03-Dec-2019 09:36:53

515 Views

The Int64.ToString() method in C# is used to convert the numeric value of this instance to its equivalent string representation.SyntaxThe syntax is as follows −public override string ToString (); public string ToString (string format);Above, the parameter format is a numeric format string.ExampleLet us now see an example − Live Demousing System; public class Demo {    public static void Main(){       long val1 = 0;       long val2 = Int64.MaxValue;       Console.WriteLine("Value1 = "+val1.ToString());       Console.WriteLine("Value2 = "+val2.ToString());       Console.WriteLine("Are they equal? = "+val1.Equals(val2));       Console.WriteLine("Value1 (HashCode) = "+val1.GetHashCode()); ... Read More

Advertisements