Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

How do I create a new object using strings and Console.ReadLine()

$
0
0

What I'm trying to do is make a banking application and at the beginning it would ask whether you want to create a savings or a current account and then asks you to enter a name for the one you selected. I'm trying to make the program create an object with a name that I've written down. It doesn't recognize the name that I've given them.

class Program{    static void Main()    {        Console.WriteLine("Enter 's' if you want a savings account. Enter 'c' if you want current account.");        string which = Console.ReadLine();        if (which == "s")        {            Console.WriteLine("Enter Name");            string name = Console.ReadLine();            Savingacc name;            name = new Savingacc();            name.mainmenu();                        }        else if (which == "c")        {            Console.WriteLine("Enter Name");            string name = Console.ReadLine();            Currentacc name;            name = new Currentacc();            name.mainmenu();        }    }}

Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>