Below are the programs to expect the output by examining the code. Program 1 can we call methods and members from Class B for the below code ? Output Answer includes : No, we will not able to call any private ,protected, Public data members or functions from the class B Program 2 what is […]
C Sharp Program to subtract 2 numbers without using arithmetic operators.
Subtract 2 numbers without using arithmetic operators – Learn how to subtract 1 from a given input number and also learn how to subtract 2 given input numbers with example programs. To subtract 1 from a number x, set all the the bits to 1 after the rightmost 1 bit.finally unset the right most bit […]
C Sharp program to Find the contiguous sub array with Maximum sum
Given an array of N integers.Find the contiguous sub array with Maximum sum. Contiguous sub array means sub-array with sequence index like (0,1,2..) or(1,2,3…) INPUTN:Size of the arrayarr[N]: arr[0],arr[1]…. arr[N-1] number of integer elements Output Print the maximum sum of the contiguous sub-array in a separate line for each test case. For Example:Input array size […]
Find missing number between 1 to N in array in C#
Find missing number in the sequence in c#- Learn how to find the missing number among the sequence of numbers from 1 to n with example Programs. For Example following are the numbers from 1 to 6 as 1,2,3,5,6.The missing number in the above sequence is 4. Input 1,2,3,5,6 Output Missing Number : 4 How […]
find position of a character in a string in C Sharp
find position of a character in a string in C# – Learn how to find the position of a character with example programs. Input string : viswanathposition of input character – s is 3 Method-1 C# program to find the index of a string using for loop C# code Output Enter String :viswanathEnter the character:wcharacter, w […]
C Sharp Program To Find Largest Number In An Array Easy Way
C# program to find largest number in an array with simple logic and example and test cases. Example:Input Array: 2 6 4 8 9Output: 9 LOGIC: Create an integer variable and store first element of the array into it, assuming this is largest value. Traverse the array using for a loop from location 1 to […]
Remove duplicate values from array in C Sharp
Learn how to remove duplicate elements in an array in C# with example. For example, The input array contains 12, 14, 23, 12, 23, 14, 23 elements, then unique elements in the give input array is 12, 14, 23. Input:12, 14, 23, 12, 23, 14, 23 in an arrayOutput: 12, 14, 23 ( only unique […]
Thread synchronization using monitors in C Sharp
Thread synchronization using monitors in C# -Learn how to synchronize threads in executing a piece of common code using locks and monitors with example programs. Lock is the keyword in C# that will ensure only one thread is executing a piece of code .The lock keyword ensures that one thread does not enter a critical […]
Thread synchronization in C Sharp
Synchronization: It is a technique that where another thread can share the piece of code (critical section) , only if the current thread complete its execution.No other thread can enter into the critical section , until the current thread finishes its execution and come out from the critical section. In multi threaded environment threads can […]
Thread Priority in C sharp
Thread Priority- A thread’s Priority property determines how much execution time it gets relative to other active threads in the operating system. Thread priorities in C# are available in ThreadPriority class from namespace System.Threading; Below C# thread priority can be assigned to a thread. Highest AboveNormal Normal BelowNormal Lowest By default “Normal” thread priority is […]