Skip to content

Instantly share code, notes, and snippets.

@kironroy
Created October 12, 2018 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kironroy/36f79aacdd68a7ef8a886f2603a8b6d7 to your computer and use it in GitHub Desktop.
Save kironroy/36f79aacdd68a7ef8a886f2603a8b6d7 to your computer and use it in GitHub Desktop.
cSharpQuiz created by kironroy - https://repl.it/@kironroy/cSharpQuiz
using System;
using System.Globalization;
namespace CSharpQuiz
{
class Program
{
static void Main(string[] args)
{
// define variables
var cSharpwelcomePrompt = "Welcome to c++ quiz ";
var correctAnswer = "Correct!\n";
var wrongAnswer = "Wrong!\n";
var quizAnswers = " Quiz answers:\n\n 1. 2002\n 2. Anders Hejlsberg\n 3. True, C# is compiled";
Console.WriteLine("What is your name");
var nameInput = Console.ReadLine().Trim();
var nameInputCaps = new CultureInfo("en-US").TextInfo.ToTitleCase(nameInput);
BreakLine();
Console.WriteLine($"Hello {nameInputCaps} {cSharpwelcomePrompt}");
// question 1
Console.WriteLine("1. When was C# created? (Type a year)");
var quizQuestion1 = Console.ReadLine().Trim();
if (quizQuestion1 == "2002")
{
Console.WriteLine(correctAnswer);
}
else
Console.WriteLine(wrongAnswer);
BreakLine();
// question 2
Console.WriteLine("2. What is the first name of C#'s creator");
var quizQuestion2 = Console.ReadLine().Trim().ToLower();
if (quizQuestion2 == "anders")
{
Console.Write(correctAnswer);
BreakLine();
}
else
Console.WriteLine(wrongAnswer);
BreakLine();
// question 3
Console.WriteLine("True or false: is C# compiled?, type true or false");
var quizQuestion3 = Console.ReadLine().Trim().ToLower();
if (quizQuestion3 == "true")
{
Console.WriteLine(correctAnswer);
}
else
Console.WriteLine(wrongAnswer);
BreakLine();
Console.WriteLine(quizAnswers);
} // main function ending bracket
// breakline method
private static void BreakLine()
{
Console.WriteLine();
}
} // class Program ending bracket
} // namespace ending bracket
MZ����@��� �!�L�!This program cannot be run in DOS mode.
$PEL� �' @@ �@�@'K@�`  H.text�  `.rsrc�@
@@.reloc `@Bp'H�!�(
*0*rp
r+p r?p rOp
r�p(
(
o
rps
o
o
(rp(
(
r,p(
(
o
rxp(
9 (
8(
(r�p(
(
o
o
r�p(
9(
(8(
(r�p(
(
o
o
rJp(
9 (
8(
( (
*(
*BSJB v4.0.30319l<#~�(#Strings�T#US$#GUID4l#BlobG �3
"*D*P\�\�*��
P �q.X ��2�!��* 1 ;K
qw!���$�
� 1*)q.1q..kD8��c<Module>CSharpQuizProgramargsConsoleSystemWriteLineReadLineStringTrimCultureInfoSystem.Globalization.ctorget_TextInfoTextInfoToTitleCaseFormatop_EqualityToLowerWriteObjectMainBreakLinemainRuntimeCompatibilityAttributeSystem.Runtime.CompilerServicesmscorlibmain.exe)Welcome to c++ quiz Correct!
Wrong!
�� Quiz answers:
1. 2002
2. Anders Hejlsberg
3. True, C# is compiled#What is your name en-USHello {0} {1}K1. When was C# created? (Type a year) 2002S2. What is the first name of C#'s creator
anderseTrue or false: is C# compiled?, type true or false true��Y��!M�?8v���       TWrapNonExceptionThrows�z\V4��h'~' p'_CorExeMainmscoree.dll�% @�0�HX@��4VS_VERSION_INFO���?DVarFileInfo$Translation��StringFileInfo�007f04b0Comments $CompanyName ,FileDescription 0FileVersion0.0.0.0,InternalNamemain(LegalCopyright ,LegalTrademarks < OriginalFilenamemain.exe$ProductName (ProductVersion �7
// c++ quiz -> https://repl.it/@kironroy/stdstringquizcpp
https://stackoverflow.com/questions/4135317/make-first-letter-of-a-string-upper-case-with-maximum-performance
@kironroy
Copy link
Author

C# quiz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment