In this tutorial we will learn how to write a c# program to check whether a given substring is present in the given string I have used Visual Studio 2019 Community for debugging purpose. But you can use any version of visual...
Tag - C# Exercises
Calculate Difference Between Two Dates in Days in C#
In this example, I’ll show you How to get the difference between two dates in days using C#. C# Code: C# class Program { static void Main(string[] args) { DateTime start = new DateTime(2019, 08, 16); DateTime end = new...
Generate Random Date in C#
In this example, I’ll show you How to generate a random date between Jan 1 1970 and the current date. C# Code: C# class RandomDateTime { DateTime start; Random gen; int range; public RandomDateTime() { start = new...
Square pyramidal number (Sum of squares) of first n natural numbers in C#
In mathematics, a pyramid number, or square pyramidal number, is a figurate number that represents the number of stacked spheres in a pyramid with a square base. Square pyramidal numbers also solve the problem of counting the...
C# Program to Add two numbers without using arithmetic Operators
Write a function Add() that returns sum of two integers. Sum of two bits can be obtained by performing XOR (^) of the two bits. Carry bit can be obtained by performing AND (&) of two bits. This example is a fine example to...
Fibonacci Series in C# with Method
We can optimize the recursive method for calculating the Fibonacci numbers by remembering (saving) the already calculated numbers in an array and making recursive call only if the number we are trying to calculate...
C# Exercises for Beginners
Welcome to Practice C# Console! There are over 20 beginner C#exercises just waiting to be solved. The best way we learn anything is by practice and exercise questions. We have started this section for those (beginner) who are...