- 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 34486 Articles for Programming
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
761 Views
The following is our array −int[] arr = new int[] { 7, 4, 6, 2 };Let’s say the given intger that should be equal to sum of two other integers is −int res = 8;To get the sum and find the equality.for (int i = 0; i < arr.Length; i++) { for (int j = 0; j < arr.Length; j++) { if (i != j) { int sum = arr[i] + arr[j]; if (sum == res) { Console.WriteLine(arr[i]); ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
2K+ Views
Declare a list.List < string > l = new List < string > ();Now, add elements to the list.// elements l.Add("Accessories"); l.Add("Footwear"); l.Add("Watches");Now convert it into a string.string str = string.Join(" ", l.ToArray());Let us see the final code to convert a list to string in C# −Exampleusing System; using System.Collections.Generic; class Demo { static void Main() { List < string > l = new List < string > (); // elements l.Add("Accessories"); l.Add("Footwear"); l.Add("Watches"); string str = string.Join(" ", l.ToArray()); Console.WriteLine(str); } }
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
669 Views
To print duplicates from a list of integers, use the ContainsKey.Below, we have first set the integers.int[] arr = { 3, 6, 3, 8, 9, 2, 2 };Then Dictionary collection is used to get the count of duplicate integers.Let us see the code to get duplicate integers.Example Live Demousing System; using System.Collections.Generic; namespace Demo { public class Program { public static void Main(string[] args) { int[] arr = { 3, 6, ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
411 Views
To format string literals in C#, use the String.Format method.In the following example, 0 is the index of the object whose string value gets inserted at that particular position −using System; namespace Demo { class Test { static void Main(string[] args) { decimal A = 15.2 m; string res = String.Format("Temperature = {0}°C.", A); Console.WriteLine(res); } } }In the following example, let us format string for double type.Example Live Demousing System; class Demo { public static void Main(String[] args) { ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
1K+ Views
To format output in C#, let us see examples to format date and double type.Set formatted output for Double type.Example Live Demousing System; class Demo { public static void Main(String[] args) { Console.WriteLine("Three decimal places..."); Console.WriteLine(String.Format("{0:0.000}", 987.383)); Console.WriteLine(String.Format("{0:0.000}", 987.38)); Console.WriteLine(String.Format("{0:0.000}", 987.7899)); Console.WriteLine("Thousands Separator..."); Console.WriteLine(String.Format("{0:0, 0.0}", 54567.46)); Console.WriteLine(String.Format("{0:0, 0}", 54567.46)); } }OutputThree decimal places... 987.383 987.380 987.790 Thousands Separator... 54, 567.5 54, 567Set formatted output for DateTimeExample Live Demousing System; static class Demo { static void Main() ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
1K+ Views
Our string is − string str = " My make "; Use the following regular expression to find the substring “make” @"\bmake\b" Here is the complete code − Example Live Demo using System; using System.Text.RegularExpressions; namespace RegExApplication { public class Program { private static void showMatch(string text, string expr) { Console.WriteLine("The Expression: " + expr); MatchCollection mc = Regex.Matches(text, expr); ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
1K+ Views
To make code reusable in C#, use Interfaces. Interfaces define properties, methods, and events, which are the members of the interface. Interfaces contain only the declaration of the members. It is the responsibility of the deriving class to define the members. It often helps in providing a standard structure that the deriving classes would follow.For example, Shape Interface −public interface IShape { void display(); }Above we have declared an Interface Shape. You can notice that it begins with a capital “I”. It is a common convention that interfaces names begin with “I”.We have not added an access specifier above ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
13K+ Views
Set a list −List < string > list1 = new List < string > () { "Lawrence", "Adams", "Pitt", "Tom" };Now use the Contains method to check if an item exits in a list or not.if (list1.Contains("Adams") == true) { Console.WriteLine("Item exists!"); }The following is the code to check if an item exists in a C# list or not.Exampleusing System; using System.Collections.Generic; public class Program { public static void Main() { List < string > list1 = new List < string > () { "Lawrence", ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
252 Views
The Logistic regression is a linear model used for binomial regression. It is used in medical science and to predict a customer’s tendency to purchase a product. It makes use of predictor variables for this purpose.Logistic Regression allows easier analysis of results in the form of odds ratios and statistical hypothesis testing.A generalized linear model has taken input for a non-linear link function. The linear model has the following form −z = c1x1 + c2x2 + … cnxn + i = ct x + iHere,c is the coefficient vector, i is the intercept value x is the observation vector
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
15K+ Views
Use the Contains() method to check if a string contains a word or not.Set the string −string s = "Together we can do so much!";Now let’s say you need to find the word “much”if (s.Contains("much") == true) { Console.WriteLine("Word found!"); }Let us see the complete code −Example Live Demousing System; public class Demo { public static void Main() { string s = "Together we can do so much!"; if (s.Contains("much") == true) { Console.WriteLine("Word found!"); } else { Console.WriteLine("Word not found!"); } } }OutputWord found!