Select an option to see the answer and solution.
Miscellaneous in C Sharp
practice.
Practice every MCQ with options. Use Show answers when you want the correct option and solution.
170
Questions
3/9
Page
Pick an option on a question to see the right answer and solution.
class Program
{
static void Main(string[] args)
{
int[] nums = {3 ,1 ,2 ,5 ,4};
var ltAvg = from n in nums
let x = nums.Average()
where n < x
select n;
Console.WriteLine("The average is " + nums.Average());
Console.ReadLine();
}
}Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
class Program
{
static void Main(string[] args)
{
String c = "Hello i love Csharp";
Boolean var;
var = c.StartsWith("hello");
Console.WriteLine(var);
Console.ReadLine();
}
}Select an option to see the answer and solution.
class MyClass
{
char chrs = 'A' ;
public IEnumerator GetEnumerator()
{
for (int i = 20; i >=0; --i)
if (i == 10) yield break;
yield return (char)((chrs + i));
}
}
class Program
{
static void Main(string[] args)
{
MyClass mc = new MyClass();
foreach (char ch in mc)
Console.Write(ch + " ");
Console.WriteLine();
Console.ReadLine();
}
}Select an option to see the answer and solution.
class Program
{
static void Main(string[] args)
{
String s1 = "one";
String s2 = string.Concat(s1 + " " + "two");
Console.WriteLine(s2);
Console.ReadLine();
}
}Select an option to see the answer and solution.
class UnsafeCode
{
unsafe static void Main()
{
int* ptrs = stackalloc int[3];
ptrs[0] = 1;
ptrs[1] = 2;
ptrs[2] = 3;
for (int i = 2; i >= 0; --i)
{
ptrs[i] = ptrs[i]* 3;
ptrs[i] = ptrs[i] + 4;
Console.WriteLine(ptrs[i]);
}
Console.ReadLine();
}
}Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
public System.Collections.IEnumerator GetEnumerator()
{
foreach (char ch in chrs)
yield return ch;
}Select an option to see the answer and solution.
class Program
{
static void Main(string[] args)
{
int y = (int)Math.Max(4,2);
int z = (int)Math.Pow(y, 2);
Console.WriteLine(z);
Console.ReadLine();
}
}Select an option to see the answer and solution.
Select an option to see the answer and solution.
class UnsafeCode
{
unsafe static void Main()
{
int m = 10;
int *mptr = &m;
int **ptr = &mptr;
int n = 20;
int *nptr = &n;
int **prt = &nptr;
m = **prt + *nptr;
n = *mptr* **prt;
Console.WriteLine(n + " " + m);
Console.ReadLine();
}
}Select an option to see the answer and solution.
class Program
{
static void Main(string[] args)
{
double x = 3.14;
int y = (int) Math.Abs(x);
Console.WriteLine(y);
}
}Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
Stack st = new Stack();
st.Push("Csharp");
st.Push(7.3);
st.Push(8);
st.Push('b');
st.Push(true);Select an option to see the answer and solution.