Karthikeya Boyini has Published 2193 Articles

How to declare member function in C# interface?

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 10:22:19

231 Views

To declare member functions in interfaces in C# −public interface InterfaceName {    // interface members    void InterfaceMemberOne();    double InterfaceMembeTwo();    void InterfaceMemberThree() } public class ClassName: InterfaceName {    void InterfaceMemberOne() {       // interface member    } }Above we saw our interface members ... Read More

What are the custom exceptions in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 10:20:05

805 Views

Like any other programming language, in C#, you can easily create a user-defined exception. User-defined exception classes are derived from the Exception class. Custom exceptions are what we call user-defined exceptions.In the below example, the exception created is not a built-in exception; it is a custom exception −TempIsZeroExceptionYou can try ... Read More

What are destructors in C# programs?

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 10:17:43

2K+ Views

A destructor is a special member function of a class that is executed whenever an object of its class goes out of scope.It has exactly the same name as that of the class with a prefixed tilde (~), for example, our class name is Demo.public Demo() { // constructor   ... Read More

How to use the sleep method in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 10:08:15

809 Views

The sleep method of the thread is used to pause the thread for a specific period.If you want to set sleep for some seconds, then use it like the following code snippet −int sleepfor = 2000; Thread.Sleep(sleepfor);You can try to run the following code to implement the sleep method of ... Read More

How do you loop through a C# array?

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 10:03:49

6K+ Views

To loop through an array in C#, use any of the loops. These loops have starting and ending value set that allows you to set or check value through iterations.C# has while, do…while, for and foreach loops to loop through an array.Let us see an example of for loop in ... Read More

Write a C# program to calculate a factorial using recursion

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 09:58:04

3K+ Views

Factorial of a number is what we are finding using a recursive function checkFact () in the below example −If the value is 1, it returns 1 since Factorial is 1 −if (n == 1) return 1;If not, then the recursive function will be called for the following iterations if ... Read More

How to use ‘is’ operator in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 09:56:17

156 Views

The "is" operator in C# checks whether the run-time type of an object is compatible with a given type or not.The following is the syntax −expr is typeHere, expr is the expression and type is the name of the typeThe following is an example showing the usage of is operator ... Read More

What MySQL ELT() function returns if the index number, provided as an argument, is higher than the number of strings?

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 08:48:29

111 Views

MySQL ELT() function returns NULL as output if the index number provided as argument is higher than the number of strings. Following is an example to make it clearer −Examplemysql> Select ELT(6, 'Ram', 'is', 'a', 'good', 'boy')As Result; +--------+ | Result | +--------+ | NULL   | +--------+ 1 row ... Read More

Extracting email addresses using regular expressions in Python

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 08:41:36

5K+ Views

Email addresses are pretty complex and do not have a standard being followed all over the world which makes it difficult to identify an email in a regex. The RFC 5322 specifies the format of an email address. We'll use this format to extract email addresses from the text.For example, ... Read More

Python program to sort out words of the sentence in ascending order

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 08:29:57

1K+ Views

In order to sort the words of a sentence in ascending order, we first need to split the sentence into words using space as the splitting point. For simplicity, we'll only be splitting on space and let the punctuation be there. We can use replace or regex to remove that ... Read More

Advertisements