- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 34494 Articles for Programming
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
297 Views
Heterogram for a string means the string isn’t having duplicate letters. For example −Mobile Cry LaptopLoop through each word of the string until the length of the string −for (int i = 0; i < len; i++) { if (val[str[i] - 'a'] == 0) val[str[i] - 'a'] = 1; else return false; }Above, len is the length of the string.Let us see the complete code −Example Live Demousing System; public class GFG { static bool checkHeterogram(string str, int len) { int []val = new int[26]; for (int i ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
1K+ Views
Firstly, set the Hex String −string str = "7D";Now, use the Convert.ToSByte() method to convert the Hex string to Hex number −Console.WriteLine(Convert.ToSByte(str, 16));Let us see the complete code −Example Live Demousing System; namespace Demo { public class Program { public static void Main(string[] args) { string str = "7D"; Console.WriteLine(Convert.ToSByte(str, 16)); } } }Output125Another way of converting Hex String to Hex Number −Example Live Demousing System; namespace Demo { public class Program { public static void Main(string[] args) { string str = "7D"; Console.WriteLine(Convert.ToInt32(str, 16)); } } }Output125
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
737 Views
Firstly, set a tuple −Tuple t = Tuple.Create(99,53);Now, convert the tuple to an array −int[] arr = new int[]{t.Item1, t.Item2};The following is the code to convert a tuple into an array −Example Live Demousing System; using System.Linq; using System.Collections.Generic; namespace Demo { public class Program { public static void Main(string[] args) { Tuple t = Tuple.Create(99,53); int[] arr = new int[]{t.Item1, t.Item2}; foreach (int val in arr) { Console.WriteLine(val); } } } }Output99 53
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
364 Views
To get the binary of Decimal, using recursion, firstly set the decimal number −int dec = 30;Now pass the value to a function −public int displayBinary(int dec) { }Now, check the condition until the decimal value is 0 and using recursion get the mod 2 of the decimal num as shown below. The recursive call will call the function again with the dec/2 value −public int displayBinary(int dec) { int res; if (dec != 0) { res = (dec % 2) + 10 * displayBinary(dec / 2); Console.Write(res); return ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
192 Views
To merge two sorted arrays into a list, firstly set two sorted arrays −int[] array1 = { 1, 2 }; int[] array2 = { 3, 4 };Add it to a list and merge −var list = new List(); for (int i = 0; i < array1.Length; i++) { list.Add(array1[i]); list.Add(array2[i]); }Now, use the ToArray() method to convert back into an array as shown below −Example Live Demousing System; using System.Collections.Generic; public class Program { public static void Main() { int[] array1 = { 56, 70, 77}; int[] array2 = ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
384 Views
To check for all vowels, firstly set the condition to check −string res = str.Where(chk =< "aeiouAEIOU".Contains(chk)).Distinct();Above, we have used the string −string str = "the quick brown fox jumps over the lazy dog";Now, using the Any() method checks whether the string has any vowels or not −if(!res.Any()) Console.WriteLine("No vowels!");Loop through the string to get the vowels −Example Live Demousing System; using System.Linq; public class Program { public static void Main() { string str = "the quick brown fox jumps over the lazy dog"; var res = str.Where(chk =< "aeiouAEIOU".Contains(chk)).Distinct(); ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
811 Views
Firstly, set the list −List myList = new List () { 5, 10, 7 };Now, set the value of a variable to 1 that would help us in multiplying −int prod = 1;Loop through and get the product −foreach(int i in myList) { prod = prod*i; }The following is the code −Example Live Demousing System; using System.Collections.Generic; public class Program { public static void Main() { List myList = new List() { 5, 10, 7 }; Console.WriteLine("List: "); foreach(int i in myList) { Console.WriteLine(i); } int prod = 1; foreach(int i in myList) { prod = prod*i; } Console.WriteLine("Product: {0}",prod); } }OutputList: 5 10 7 Product: 350
![Giri Raju](https://www.tutorialspoint.com/assets/profiles/13536/profile/60_72105-1512540773.jpg)
1K+ Views
Firstly, set the number as string −string num = "1000000.8765";Now, work around differently for number before and after the decimal −string withoutDecimals = num.Substring(0, num.IndexOf(".")); string withDecimals = num.Substring(num.IndexOf("."));Use the ToString() method to set the format for 1000 separators −ToString("#,##0")The following is the complete code to display number with commas as 1000 separators −Example Live Demousing System; public class Program { public static void Main() { string num = "1000000.8765"; string withoutDecimals = num.Substring(0, num.IndexOf(".")); string withDecimals = num.Substring(num.IndexOf(".")); withoutDecimals = Convert.ToInt32(withoutDecimals).ToString("#,##0"); Console.WriteLine(withoutDecimals + withDecimals); } }Output1,000,000.8765