Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 2242 of 3366
553 Views
To get all the interfaces implemented or inherited by the current Type, the code is as follows −Example Live Demousing System; public class Demo { public static void Main() { Type type = typeof(float); Type myInterface = type.GetInterface("IFormattable", true); Type[] myInterfaces = type.GetInterfaces(); Console.WriteLine("Interface = "+myInterface); Console.WriteLine("All the Interfaces..."); for (int i = 0; i < myInterfaces.Length; i++) Console.WriteLine(""+myInterfaces[i]); } }OutputThis will produce the following output −Interface = System.IFormattable All the Interfaces... System.IComparable System.IFormattable System.IConvertible System.IComparable`1[System.Single] System.IEquatable`1[System.Single]Let us see another example −Example Live ... Read More
130 Views
To get a specific interface implemented or inherited by the current Type, the code is as follows −Example Live Demousing System; public class Demo { public static void Main() { Type type = typeof(double); Type myInterface = type.GetInterface("IFormattable"); Console.WriteLine("Interface = "+myInterface); } }OutputThis will produce the following output −Interface = System.IFormattableExampleLet us see another example − Live Demousing System; public class Demo { public static void Main() { Type type = typeof(float); Type myInterface = type.GetInterface("IFormattable",true); Console.WriteLine("Interface = "+myInterface); } }OutputThis will produce the following output −Interface = System.IFormattable
1K+ Views
The lambda expressions were introduced in Java 8 and facilitate functional programming. A lambda expression works nicely together only with functional interfaces and we cannot use lambda expressions with more than one abstract method.Characteristics of Lambda ExpressionOptional Type Declaration − There is no need to declare the type of a parameter. The compiler inferences the same from the value of the parameter.Optional Parenthesis around Parameter − There is no need to declare a single parameter in parenthesis. For multiple parameters, parentheses are required.Optional Curly Braces − There is no need to use curly braces in the expression body if the body contains a ... Read More
164 Views
To get the TypeCode for value type UInt64, the code is as follows −Example Live Demousing System; public class Demo { public static void Main() { ulong val1 = 55; ulong val2 = 100; TypeCode type1 = val1.GetTypeCode(); TypeCode type2 = val2.GetTypeCode(); Console.WriteLine("Typecode for val1 = "+type1); Console.WriteLine("Typecode for val2 = "+type2); } }OutputThis will produce the following output −Typecode for val1 = UInt64 Typecode for val2 = UInt64ExampleLet us see another example −using System; public class Demo { public ... Read More
452 Views
To check whether the Dictionary contains a specific value or not, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo { public static void Main() { Dictionary dict = new Dictionary(); dict.Add("One", "John"); dict.Add("Two", "Tom"); dict.Add("Three", "Jacob"); dict.Add("Four", "Kevin"); dict.Add("Five", "Nathan"); Console.WriteLine("Count of elements = "+dict.Count); Console.WriteLine("Key/value pairs..."); foreach(KeyValuePair res in dict) { Console.WriteLine("Key = {0}, Value = {1}", res.Key, res.Value); ... Read More
543 Views
The parameters are used to pass and receive data from a method. Let us first see the syntax −Access Specifier − This determines the visibility of a variable or a method from another class.Return type − A method may return a value. The return type is the data type of the value the method returns. If the method is not returning any values, then the return type is void.Method name − Method name is a unique identifier and it is case sensitive. It cannot be same as any other identifier declared in the class.Parameter list − Enclosed between parentheses, the ... Read More
270 Views
To reverse the order of the elements in the entire List, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo { public static void Main(String[] args) { List list = new List(); list.Add("One"); list.Add("Two"); list.Add("Three"); list.Add("Four"); list.Add("Five"); list.Add("Six"); list.Add("Seven"); list.Add("Eight"); Console.WriteLine("Enumerator iterates through the list elements..."); List.Enumerator demoEnum = list.GetEnumerator(); while (demoEnum.MoveNext()) { string res ... Read More
201 Views
To reverse the order of the elements in the entire ArrayList, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo { public static void Main(String[] args) { ArrayList list1 = new ArrayList(); list1.Add("A"); list1.Add("B"); list1.Add("C"); list1.Add("D"); list1.Add("E"); list1.Add("F"); list1.Add("G"); list1.Add("H"); list1.Add("I"); Console.WriteLine("Elements in ArrayList1..."); foreach (string res in list1) { Console.WriteLine(res); } ... Read More
101 Views
To set all bits in the BitArray to the specified value, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo { public static void Main() { BitArray arr = new BitArray(5); arr[0] = false; arr[1] = false; arr[2] = false; arr[3] = false; Console.WriteLine("BitArray..."); foreach(Object ob in arr) { Console.WriteLine(ob); } arr.SetAll(true); Console.WriteLine("Updated BitArray..."); foreach(Object ob in arr) ... Read More
305 Views
Byte Struct in C# represents an 8-bit unsigned integer. Following are the fields −Sr.noField & Description1MaxValueRepresents the largest possible value of a Byte. This field is constant.2MinValueRepresents the smallest possible value of a Byte. This field is constant.Following are some of the methods −Sr.noField & Description1CompareTo(Byte)Compares this instance to a specified 8-bit unsigned integer and returns an indication of their relative values.2CompareTo(Object)Compares this instance to a specified object and returns an indication of their relative values.3Equals(Byte)Returns a value indicating whether this instance and a specified Byte object represent the same value.4Equals(Object)Returns a value indicating whether this instance is equal to ... Read More