Set the string as empty using the string.Empty in C# −string myStr = string.Empty;To check whether it is a string or not, use the IsNullOrEmpty() method −if (string.IsNullOrEmpty(myStr)) { Console.WriteLine("String is empty or null!"); }The following is an example −Example Live Demousing System; namespace Demo { public class Program { public static void Main(string[] args) { string myStr = string.Empty; if (string.IsNullOrEmpty(myStr)) { Console.WriteLine("String is empty or null!"); } else { Console.WriteLine("String isn't empty or null!"); } } } }OutputString is empty or null!
Since we cannot use the MINUS query in MySQL, we will use JOIN to simulate the MINUS query. It can be understood with the help of the following example −ExampleIn this example, we are two tables namely Student_detail and Student_info having the following data −mysql> Select * from Student_detail; +-----------+---------+------------+------------+ | studentid | Name | Address | Subject | +-----------+---------+------------+------------+ | 101 | YashPal | Amritsar | History | | 105 | Gaurav | Chandigarh | Literature | | 130 | Ram | Jhansi ... Read More
InheritanceWith Inheritance, you can designate that the new class should inherit the members of an existing class. This existing class is called the baseclass, and the new class is referred to as the derived class. Inheritance implements the IS-A relationship. For example, mammal IS A animal, dog IS-A mammal hence dog IS-A animal as well, and so on.For example, A base class Shape has a derived classes like Circle, Square, Rectangle, etc.CompositionUnder Composition, if the parent object is deleted, then the child object also loses its status. Composition is a special type of Aggregation and gives a part-of relationship.For example, ... Read More
With the help of SHOW STATUS statement, we can get the count of MySQL event-related operations. It can be used as follows −mysql> SHOW STATUS LIKE '%event%'; +--------------------------+-------+ | Variable_name | Value | +--------------------------+-------+ | Com_alter_event | 16 | | Com_create_event | 6 | | Com_drop_event | 4 | | Com_show_binlog_events | 0 | | Com_show_create_event | 0 | | Com_show_events | 4 | | Com_show_relaylog_events | 0 | +--------------------------+-------+ 7 rows in set (0.17 sec)
A nested class is a class declared in another enclosing class and it has inner as well as outer class. It is a member of its enclosing class and the members of an enclosing class have no access to members of a nested classLet us see an example code snippet of nested classes in C#.Here, class Two is a local inner class −Exampleclass One { public int num1; public class Two { public int num2; } } class Demo { static void Main() { One x = new One(); ... Read More
We can delete a particular existing column from a MySQL table by using the DROP statement along with an ALTER statement. Its syntax would be as follows −SyntaxALTER TABLE table_name DROP column_name;Here, table_name is the name of the table from which we want to delete the column.Column_name is the name of the column which is to be deleted from the table.ExampleIn this example, we are deleting the column ‘address’ from table ‘student_detail’ as follows −mysql> select * from student_detail; +-----------+-------------+----------+ | Studentid | StudentName | address | +-----------+-------------+----------+ | 100 | Gaurav | Delhi ... Read More
Let’s say we need to find the following file −E:ew.txtTo check the existence of the above file, use the Exists() method −if (File.Exists(@"E:ew.txt")) { Console.WriteLine("File exists..."); }Here is the complete code to check the existence of a file −Example Live Demousing System; using System.IO; public class Demo { public static void Main() { if (File.Exists(@"E:ew.txt")) { Console.WriteLine("File exists..."); } else { Console.WriteLine("File does not exist in the E directory!"); } } }OutputFile does not exist in the E directory!
Use the Truncate method in C# to remove all the numbers after decimal places.Let’s say the following is our number −20.35MTo remove the numbers after decimal places, use Truncate() −decimal.Truncate(20.35M)Let us see the comple code −Exampleusing System; using System.Linq; class Demo { static void Main() { decimal dc = 20.35M; Console.WriteLine(dc.Truncate(val)); } }
It can be done with the help of the INFORMATION_SCHEMA database. The following statement will give us the metadata of events −mysql> SELECT * from INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME LIKE '%event%' A ND EVENT_SCHEMA = 'query'\G *************************** 1. row *************************** EVENT_CATALOG: def EVENT_SCHEMA: query EVENT_NAME: testing_event6 DEFINER: root@localhost TIME_ZONE: SYSTEM EVENT_BODY: SQL EVENT_DEFINITION: INSERT INTO event_message(message, generated_at) values('EVENT ALTERED', NOW()) EVENT_TYPE: ONE TIME EXECUTE_AT: 2017-11-22 20:03:52 ... Read More
The ToEven property is used with the MidpointRounding Enumeration to round a number to the nearest even number.Declare and initialize a decimal number −decimal val = 70.45M;To rounde a number to the nearest even number −decimal.Round(val, 0, MidpointRounding.ToEven)Here is the complete code −Example Live Demousing System; using System.Linq; class Demo { static void Main() { decimal val = 70.45M; Console.WriteLine(decimal.Round(val, 0, MidpointRounding.ToEven)); } }Output70
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP