Tue , Mar 04 2025
I am talking about my interview experience during the Cognizant walk-in drive for .NET Developer and Lead positions in Indore.
var
and dynamic
// var: The type is determined at compile time
var number = 10; // 'number' is of type int
// dynamic: The type is determined at runtime
dynamic obj = 10;
obj = "Hello"; // 'obj' is now of type string
ref
and out
keywordsvoid SampleRef(ref int x)
{
x = 20;
}
void SampleOut(out int x)
{
x = 30;
}
int a = 10;
SampleRef(ref a); // a is now 20
int b;
SampleOut(out b); // b is now 30
public delegate void DisplayMessage(string message);
public class Program
{
public static void Main()
{
DisplayMessage dm = ShowMessage;
dm("Hello, Delegate!");
}
public static void ShowMessage(string message)
{
Console.WriteLine(message);
}
}
// SOLID Principles:
// S: Single Responsibility Principle
// O: Open/Closed Principle
// L: Liskov Substitution Principle
// I: Interface Segregation Principle
// D: Dependency Inversion Principle
public class Bird
{
public virtual void Fly() { Console.WriteLine("Flying"); }
}
public class Sparrow : Bird { }
public class Ostrich : Bird
{
public override void Fly()
{
throw new InvalidOperationException("Ostriches cannot fly");
}
}
varchar
and char
data types in SQL// varchar: Variable-length character data
// char: Fixed-length character data
// Default constructor
MyClass obj1 = new MyClass();
// Parameterized constructor
// Parameterized constructor
MyClass obj2 = new MyClass(10);
// Singleton pattern
public sealed class Singleton
{
private static readonly Singleton instance = new Singleton();
private Singleton() { }
public static Singleton Instance
{
get { return instance; }
}
}
// Singleton Pattern Example
public sealed class Singleton
{
private static readonly Singleton instance = new Singleton();
private Singleton() { }
public static Singleton Instance
{
get { return instance; }
}
}
public class Program
{
public static void Main()
{
string str = "Hello, World!";
string reversedStr = ReverseString(str);
Console.WriteLine(reversedStr);
}
public static string ReverseString(string str)
{
char[] charArray = str.ToCharArray();
Array.Reverse(charArray);
return new string(charArray);
}
}
public class Program
{
public static void Main()
{
int[] numbers = { 1, 2, 2, 3, 4, 4, 5 };
int[] distinctNumbers = RemoveDuplicates(numbers);
Console.WriteLine(string.Join(", ", distinctNumbers));
}
public static int[] RemoveDuplicates(int[] numbers)
{
return numbers.Distinct().ToArray();
}
}
The interview went well, but I haven't received any feedback yet. They mentioned that feedback would be shared in the upcoming days, and I am still waiting for it.
Thanks, everyone, for reading about my interview experience and the process involved.
I am an engineer with over 10 years of experience, passionate about using my knowledge and skills to make a difference in the world. By writing on LifeDB, I aim to share my thoughts, ideas, and insights to inspire positive change and contribute to society. I believe that even small ideas can create big impacts, and I am committed to giving back to the community in every way I can.
Leave a Reply