Skip to content

Instantly share code, notes, and snippets.

@rozer007
rozer007 / Faq.txt
Last active November 26, 2021 08:16
operator ,math function and decision making in c#
Q1. What will happen if we don't write break after a case in switch case?
ans: The code under that case will be executed and execution it will move to the next case untill it meet a break statement.
Q2. Can goto work as loop?
ans: Yes ,but it is not a good way of using goto statement.
Q3.How does Math.abs() work?
ans: It will give the absolute value of a number ie. for -2 it will give 2.Here the signed are ignored.
Q4. Differnce between ceiling and round ?
@rozer007
rozer007 / Faq.txt
Last active December 4, 2021 04:28
loops on c#
Q1) What does break statement do?
ans: This will terminate the loop.
Q2) What does continue do?
ans: This will skip the rest of the code of the loop and start the next iteration.
Q3) Why does do while loop execute atleast one even the condition is false?
ans: It is because the condition is check at the end of the loop.
Q4) Difference between other loop and foreach loop?
@rozer007
rozer007 / Faq.txt
Last active November 24, 2021 04:43
Array in C#
Q1) Difference between List and array?
ans Array are static with a fixed size whereas List are dynamic and size can be change according to our need.
Q2) What does split function do?
ans: It convert a string into a array by spliting the string by a character and each word is stores as an element in an array.
Q3) How can we add at the front of a list?
ans: We can use the Insert function to add at index 0.
eg. list.Insert(0,element you want to add).
@rozer007
rozer007 / Mcq.txt
Created November 23, 2021 12:10
STRING , STRINGBUILDER AND ITS FUNCTION IN C#
Q1) What will be the output of this code?
string str="hello pepcoder";
Console.WriteLine(str.Substring(0,8));
a) hello pe
b) hello pep
c) ello pe
d) ello pep
ans: b)
@rozer007
rozer007 / faq.txt
Created November 24, 2021 04:43
List and exception handling in c#
Q1) How to create a 2d array in list?
ans: List<List< data_type>> 2dlist = new List<List< data_type>>();
2dlist.Add(new List<data_type>())
Q2) How can we raise an exception in c#?
ans: We can raise an exception manually in c# using the throw keyword.
Q3) How to get the number of element in a nth dimension of a List?
ans: We can get the number of element by this statement list[n-1].Count;
@rozer007
rozer007 / Faq.txt
Last active November 24, 2021 05:26
class and object in c#
1. What are getter setter methods?
Ans - Getter and Setter methods are used to retrieve and set the data of instance variables in class.
2. How can we write a construtor function in c#
ans: A constructor function in C# must have the same name as the class , and we either give argument or no parameter.
3. What is the keyword that is use in setter method when we write a setter manually?
ans: value keyword is use to write a setter method.
4. How can we access a static variable?
@rozer007
rozer007 / Faq.txt
Created November 24, 2021 05:35
Inheritanec in c#
1. What is the need of inheritance?
Ans- We use inheritance because it provides us code reusability and reduces our code. It also reduces data redundancy and duplicacy.
2. Does C# supoorts multiple inheritance?
Ans- No C# only doesn't support multiple inheritance but we can use modules to implement multiple inheritance.
3. How can we create a method to override the method in base class
ans: we will use the new keyword use the function name while declaring a function for overriding.
@rozer007
rozer007 / Faq.txt
Created November 24, 2021 05:51
ABSTRACT CLASS ,INTERFACE AND OPERATOR OVERLOADING IN C#
Q1 What type of method is define in interface?
ans: Only abstact method can be define in an interface.
Q2 Can we write the body of the function in simple method in abstract class.
ans : yes we can write the body of the simlpe method but we cannot write for the abstract method.
Q3.What type of polymorphism is operator overloading?
ans:It is a compile time polymorphism.
Q4 what keyword is use to access the abstract method from the abstract class?
@rozer007
rozer007 / Mcq.txt
Created November 24, 2021 06:03
GENERIC , ENUMERATION AND STRUCTURE IN C#
Q1 What is the correct way of defining a generic class with only one variable?
a. class class_name<T>
b. class class_name<Tkey>
c. None of the above
d. Both a and b
ans d
Q2 what keyword is use to define enumeration in c#
@rozer007
rozer007 / Faq.txt
Created November 24, 2021 06:43
Delegate and lambda expression and files in c#
Q1 can a static method associated with a class having same parameter and retunn typecall delegate?
ans : yes , it can be call just the return typr and parameter must be satisfied.
Q2 What is a lambda operator?
ans: this "=>" is known as the lambda operator in c#.
Q3. How can we know that we have reach the end of a file while reading file?
ans: we just need to check if the file.ReadLine == null, if null then it had reached the end.
Q4 What is anonymous function?