AmitDiwan has Published 10744 Articles

Get a specific field of the current type C#

AmitDiwan

AmitDiwan

Updated on 10-Dec-2019 09:51:35

441 Views

To get a specific field of the current type in C#, the code is as follows −Example Live Demousing System; using System.Reflection; public class Demo {    public static void Main() {    Type type = typeof(Subject);       try {          FieldInfo fieldInfo = type.GetField("SubName");   ... Read More

Add the specified key and value into the ListDictionary in C#

AmitDiwan

AmitDiwan

Updated on 10-Dec-2019 09:49:45

149 Views

To add the specified key and value into the ListDictionary, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Specialized; public class Demo {    public static void Main(){       ListDictionary dict = new ListDictionary();       dict.Add("1", "One");       dict.Add("2", "Two");   ... Read More

Get the array of the values of the constants in the current enum type in C#

AmitDiwan

AmitDiwan

Updated on 10-Dec-2019 09:48:24

125 Views

To get the array of the values of the constants in the current enumeration type, the code is as follows −Example Live Demousing System; public class Demo {    enum Vehicle {Car, Bus, Bike, Airplane}    public static void Main() {       try {          Type ... Read More

Add element to HashSet in C#

AmitDiwan

AmitDiwan

Updated on 10-Dec-2019 09:47:07

321 Views

To add the element to HashSet, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main(String[] args){       HashSet set1 = new HashSet();       set1.Add("A");       set1.Add("B");       set1.Add("C");       set1.Add("D"); ... Read More

Get the fields of the current Type in C#

AmitDiwan

AmitDiwan

Updated on 10-Dec-2019 09:45:21

281 Views

To get the fields of the current Type, the code is as follows −Example Live Demousing System; using System.Reflection; public class Demo {    public static void Main() {       Type type = typeof(System.String);       FieldInfo [] fields = type.GetFields(BindingFlags.Static | BindingFlags.NonPublic);       Console.WriteLine ("Following ... Read More

Get the handle for the Type of a specified object C#

AmitDiwan

AmitDiwan

Updated on 10-Dec-2019 09:41:48

228 Views

To get the handle for the Type of a specified object, the code is as follows −Example Live Demousing System; public class Demo {    public static void Main() {       Type type1 = typeof(System.Type);       RuntimeTypeHandle typeHandle = Type.GetTypeHandle(type1);       Type type = Type.GetTypeFromHandle(typeHandle); ... Read More

Check whether the Dictionary has the specified key or not in C#

AmitDiwan

AmitDiwan

Updated on 10-Dec-2019 09:39:46

154 Views

To check whether the Dictionary has the specified key 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");       ... Read More

Perform multiple counting without using MySQL COUNT()?

AmitDiwan

AmitDiwan

Updated on 10-Dec-2019 08:17:27

275 Views

To count, you can use SUM() along with CASE statement for conditions. Let us first create a table −mysql> create table DemoTable1485    -> (    -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> StudentName varchar(20),    -> StudentSubject varchar(20)    -> ); Query OK, 0 rows affected ... Read More

Indicate whether the specified Unicode character is white space in C#

AmitDiwan

AmitDiwan

Updated on 10-Dec-2019 08:16:29

221 Views

To indicate whether the specified Unicode character is white space, the code is as follows −Example Live Demousing System; public class Demo {    public static void Main() {       bool res;       char val = ' ';       Console.WriteLine("Value = "+val);       ... Read More

Insert MAX(col)+1 into the same MySQL table?

AmitDiwan

AmitDiwan

Updated on 10-Dec-2019 08:15:01

599 Views

Let us first create a table −mysql> create table DemoTable1484    -> (    -> Id int    -> ); Query OK, 0 rows affected (0.46 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1484 values(100); Query OK, 1 row affected (0.25 sec) mysql> insert into ... Read More

Advertisements