Skip to content
Loading
  • Aniket Rana
    +1
    Hello Jayce Mcintosh,
     
           Without file or database this is possible but you have to use Client side storage 
    like , session ,querystring , or store in datatable and datatable store in session and also array is great option . 
    +1
  • +1
    1. class Program  
    2.     {  
    3.   
    4.         static void Main(string[] args)  
    5.         {  
    6.             
    7.             int User = 0;  
    8.             int Position = 0;  
    9.             string FirstUserName;  
    10.             string SecondUserName;  
    11.             string ThirdUserName;  
    12.             string FourthUserName;  
    13.             int FirstUserPosition;  
    14.             int SecondUserPosition;  
    15.             int ThirdUserPosition;  
    16.             int FourthUserPosition;  
    17.             do  
    18.             {  
    19.                 Console.WriteLine("Please Enter FirstUser Name");  
    20.                 FirstUserName = Console.ReadLine();  
    21.                 Console.WriteLine("Please Enter SecondUser Name");  
    22.                 SecondUserName = Console.ReadLine();  
    23.                 Console.WriteLine("Please Enter ThirdUser Name");  
    24.                 ThirdUserName = Console.ReadLine();  
    25.                 Console.WriteLine("Please Enter FourthUser Name");  
    26.                 FourthUserName = Console.ReadLine();  
    27.                 Console.WriteLine("");  
    28.                 User += 4;  
    29.                 do  
    30.                 {  
    31.                     Console.WriteLine("{0}\nPlease Select Your Postion : 1 - First , 2 - Second, 3 - Third , 4 - Fourth", FirstUserName);  
    32.                     FirstUserPosition = Convert.ToInt32(Console.ReadLine());  
    33.                     #region Switch Statement For First User Position  
    34.                     switch (FirstUserPosition)  
    35.                     {  
    36.                         case 1:  
    37.                             FirstUserPosition = 10;  
    38.                             break;  
    39.                         case 2:  
    40.                             FirstUserPosition = 5;  
    41.                             break;  
    42.                         case 3:  
    43.                             FirstUserPosition = 3;  
    44.                             break;  
    45.                         case 4:  
    46.                             FirstUserPosition = 0;  
    47.                             break;  
    48.                     }  
    49.                     #endregion  
    50.   
    51.                     Console.WriteLine("{0}\nPlease Select Your Postion : 1 - First , 2 - Second, 3 - Third , 4 - Fourth", SecondUserName);  
    52.                     SecondUserPosition = Convert.ToInt32(Console.ReadLine());  
    53.                     #region Switch Statement For Second User Position  
    54.                     switch (SecondUserPosition)  
    55.                     {  
    56.                         case 1:  
    57.                             SecondUserPosition = 10;  
    58.                             break;  
    59.                         case 2:  
    60.                             SecondUserPosition = 5;  
    61.                             break;  
    62.                         case 3:  
    63.                             SecondUserPosition = 3;  
    64.                             break;  
    65.                         case 4:  
    66.                             SecondUserPosition = 0;  
    67.                             break;  
    68.                     }  
    69.                     #endregion  
    70.   
    71.                     Console.WriteLine("{0}\nPlease Select Your Postion : 1 - First , 2 - Second, 3 - Third , 4 - Fourth", ThirdUserName);  
    72.                     ThirdUserPosition = Convert.ToInt32(Console.ReadLine());  
    73.                     #region Switch Statement For Third User Position  
    74.                     switch (ThirdUserPosition)  
    75.                     {  
    76.                         case 1:  
    77.                             ThirdUserPosition = 10;  
    78.                             break;  
    79.                         case 2:  
    80.                             ThirdUserPosition = 5;  
    81.                             break;  
    82.                         case 3:  
    83.                             ThirdUserPosition = 3;  
    84.                             break;  
    85.                         case 4:  
    86.                             ThirdUserPosition = 0;  
    87.                             break;  
    88.                     }  
    89.                     #endregion  
    90.                      
    91.                     Console.WriteLine("{0}\nPlease Select Your Postion : 1 - First , 2 - Second, 3 - Third , 4 - Fourth", FourthUserName);  
    92.                     FourthUserPosition = Convert.ToInt32(Console.ReadLine());  
    93.                     #region Switch Statement For Fourth User Position  
    94.                     switch (FourthUserPosition)  
    95.                     {  
    96.                         case 1:  
    97.                             FourthUserPosition = 10;  
    98.                             break;  
    99.                         case 2:  
    100.                             FourthUserPosition = 5;  
    101.                             break;  
    102.                         case 3:  
    103.                             FourthUserPosition = 3;  
    104.                             break;  
    105.                         case 4:  
    106.                             FourthUserPosition = 0;  
    107.                             break;  
    108.                     }  
    109.                     #endregion  
    110.   
    111.                     Position += 4;  
    112.                 } while (Position != User);  
    113.             } while (User != 4);  
    114.   
    115.             Console.WriteLine("Name : {0},Point {1}",FirstUserName, FirstUserPosition);  
    116.             Console.WriteLine("");  
    117.             Console.WriteLine("Name : {0},Point {1}", SecondUserName, SecondUserPosition);  
    118.             Console.WriteLine("");  
    119.             Console.WriteLine("Name : {0},Point {1}", ThirdUserName, ThirdUserPosition);  
    120.             Console.WriteLine("");  
    121.             Console.WriteLine("Name : {0},Point {1}", FourthUserName, FourthUserPosition);  
    122.   
    123.             Console.ReadKey();  
    124.         }  
    125.     }  
    +1
  • Aniket Rana
    +1
    refer this ,
     
    https://stackoverflow.com/questions/1941928/best-way-to-store-data-locally-in-net-c
     
    you can store  data in List or array
    +1
  • +1
    I did it For FirstUserPosition other you can like same like that also you can ask as many question as you want i will try my best to help you and qive you appropriate answer 
    1. class Program  
    2.     {  
    3.   
    4.         static void Main(string[] args)  
    5.         {  
    6.             Console.ForegroundColor = ConsoleColor.White;  
    7.   
    8.             int User = 0;  
    9.             int Position = 0;  
    10.             string FirstUserName;  
    11.             string SecondUserName;  
    12.             string ThirdUserName;  
    13.             string FourthUserName;  
    14.             string FirstUserPosition;  
    15.             int SecondUserPosition;  
    16.             int ThirdUserPosition;  
    17.             int FourthUserPosition;  
    18.             do  
    19.             {  
    20.                 Console.WriteLine("Please Enter FirstUser Name");  
    21.                 FirstUserName = Console.ReadLine();  
    22.                 Console.WriteLine("Please Enter SecondUser Name");  
    23.                 SecondUserName = Console.ReadLine();  
    24.                 Console.WriteLine("Please Enter ThirdUser Name");  
    25.                 ThirdUserName = Console.ReadLine();  
    26.                 Console.WriteLine("Please Enter FourthUser Name");  
    27.                 FourthUserName = Console.ReadLine();  
    28.                 Console.WriteLine("");  
    29.                 User += 4;  
    30.                 do  
    31.                 {  
    32.                     int result = 0;  
    33.                     bool Casting;  
    34.                     Start:  
    35.                     Console.WriteLine("{0}\nPlease Select Your Postion : 1 - First , 2 - Second, 3 - Third , 4 - Fourth", FirstUserName);  
    36.                     FirstUserPosition = Console.ReadLine();  
    37.                     Casting = Int32.TryParse(FirstUserPosition, out result);  
    38.                       
    39.                     if (Casting)  
    40.                     {  
    41.                         Console.WriteLine(FirstUserPosition);  
    42.                     }  
    43.                     else  
    44.                     {  
    45.                         Console.WriteLine("Please Enter a Valid Number");  
    46.                         goto Start;  
    47.                     }  
    48.                       
    49.   
    50.                     Console.WriteLine("{0}\nPlease Select Your Postion : 1 - First , 2 - Second, 3 - Third , 4 - Fourth", SecondUserName);  
    51.                     SecondUserPosition = Convert.ToInt32(Console.ReadLine());  
    52.                     #region Switch Statement For Second User Position      
    53.                     switch (SecondUserPosition)  
    54.                     {  
    55.                         case 1:  
    56.                             SecondUserPosition = 10;  
    57.                             break;  
    58.                         case 2:  
    59.                             SecondUserPosition = 5;  
    60.                             break;  
    61.                         case 3:  
    62.                             SecondUserPosition = 3;  
    63.                             break;  
    64.                         case 4:  
    65.                             SecondUserPosition = 0;  
    66.                             break;  
    67.   
    68.                     }  
    69.                     #endregion  
    70.   
    71.                     if (SecondUserPosition == Convert.ToInt32(FirstUserPosition))  
    72.                     {  
    73.   
    74.                         do  
    75.                         {  
    76.                             Console.ForegroundColor = ConsoleColor.Red;  
    77.                             Console.WriteLine("Invalid Position");  
    78.                             Console.WriteLine("{0}\nPlease Select Your Postion : 1 - First , 2 - Second, 3 - Third , 4 - Fourth", SecondUserName);  
    79.                             SecondUserPosition = Convert.ToInt32(Console.ReadLine());  
    80.                             #region Switch Statement For Second User Position      
    81.                             switch (SecondUserPosition)  
    82.                             {  
    83.                                 case 1:  
    84.                                     SecondUserPosition = 10;  
    85.                                     break;  
    86.                                 case 2:  
    87.                                     SecondUserPosition = 5;  
    88.                                     break;  
    89.                                 case 3:  
    90.                                     SecondUserPosition = 3;  
    91.                                     break;  
    92.                                 case 4:  
    93.                                     SecondUserPosition = 0;  
    94.                                     break;  
    95.   
    96.                             }  
    97.                             #endregion  
    98.                             Console.ForegroundColor = ConsoleColor.White;  
    99.                         } while (SecondUserPosition == Convert.ToInt32(FirstUserPosition));  
    100.                     }  
    101.   
    102.   
    103.                     Console.WriteLine("{0}\nPlease Select Your Postion : 1 - First , 2 - Second, 3 - Third , 4 - Fourth", ThirdUserName);  
    104.                     ThirdUserPosition = Convert.ToInt32(Console.ReadLine());  
    105.                     #region Switch Statement For Third User Position      
    106.                     switch (ThirdUserPosition)  
    107.                     {  
    108.                         case 1:  
    109.                             ThirdUserPosition = 10;  
    110.                             break;  
    111.                         case 2:  
    112.                             ThirdUserPosition = 5;  
    113.                             break;  
    114.                         case 3:  
    115.                             ThirdUserPosition = 3;  
    116.                             break;  
    117.                         case 4:  
    118.                             ThirdUserPosition = 0;  
    119.                             break;  
    120.                     }  
    121.                     #endregion  
    122.   
    123.   
    124.   
    125.   
    126.   
    127.                     Console.WriteLine("{0}\nPlease Select Your Postion : 1 - First , 2 - Second, 3 - Third , 4 - Fourth", FourthUserName);  
    128.                     FourthUserPosition = Convert.ToInt32(Console.ReadLine());  
    129.                     #region Switch Statement For Fourth User Position      
    130.                     switch (FourthUserPosition)  
    131.                     {  
    132.                         case 1:  
    133.                             FourthUserPosition = 10;  
    134.                             break;  
    135.                         case 2:  
    136.                             FourthUserPosition = 5;  
    137.                             break;  
    138.                         case 3:  
    139.                             FourthUserPosition = 3;  
    140.                             break;  
    141.                         case 4:  
    142.                             FourthUserPosition = 0;  
    143.                             break;  
    144.                     }  
    145.                     #endregion  
    146.   
    147.                     Position += 4;  
    148.                 } while (Position != User);  
    149.             } while (User != 4);  
    150.   
    151.             Console.WriteLine("Name : {0},Point {1}", FirstUserName, FirstUserPosition);  
    152.             Console.WriteLine("");  
    153.             Console.WriteLine("Name : {0},Point {1}", SecondUserName, SecondUserPosition);  
    154.             Console.WriteLine("");  
    155.             Console.WriteLine("Name : {0},Point {1}", ThirdUserName, ThirdUserPosition);  
    156.             Console.WriteLine("");  
    157.             Console.WriteLine("Name : {0},Point {1}", FourthUserName, FourthUserPosition);  
    158.   
    159.   
    160.   
    161.             Console.ReadKey();  
    162.         }  
    163.     }  
    +1
  • 0
    Brilliant thank you so much
    0
  • 0
    Abdul Salam fantastic answer! Is there any easy way to make it so all users can't enter the same position? I.e. all players finish first? Thanks again!
    0
  • 0
    Abdul thank you again, very much appreciated :)
    0
  • 0
    Absolute final question now then I will try this in visual c# (works perfectly in console by the way). How can I make the user only enter a number for position and not a string (this throws an error), and positions entered are only between 1 to 4 (you can enter 5, 6, 7 etc.). Thanks again and this is the final question!
    0
  • 0
    Genius Abdul thank you. That is all questions I have for now. I may be asking another in a few weeks if that's OK. Thanks again much appreciated!
    0
  • 0
    You Welcome Jayce Mcintosh when ever you want to ask. 
    0
  • 0
    Hello again. I have now put the code in to Visual Studio (with text boxes etc.), got it working and learnt a lot from doing so. My final question (and this is really going to test you) is how to make it so each user can enter 3 events (instead of just the one) with same rules as before (i.e. 10 points for first, 5 for second etc. (but for each event)) but when all results are inputted the totals added are displayed. If you would be so kind as to help with this, please could you do it in the console as I have learnt a lot putting it in to Visual Studio. Many thanks again I cannot tell you how grateful I am for this :) Image of what I mean is below:
    0
  • 0
    Dear Jayce Mcintosh,
     
    Your Project Image is Not Clear if possible you can upload your project as rar file or images.
    0
  • 0
    Hi Abdul, I have attached RAR file of image if that helps. If you want me to send you the full project please let  know and I will :) thanks
    0
  • 0
    I Create for First User You Can Check Now
    0