Skip to content

Instantly share code, notes, and snippets.

@kironroy kironroy/main.cs
Created Oct 12, 2018

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

commented Oct 12, 2018

C# quiz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.