String calculator [closed]

Regular Expression evaluation can be done using DataTable.Compute method (from MSDN) : Computes the given expression on the current rows that pass the filter criteria. Try this: using System.Data;//import this namespace string math = “100 * 5 – 2”; string value = new DataTable().Compute(math, null).ToString();

C# Count Vowels

Right now, you’re checking whether the sentence as a whole contains any vowels, once for each character. You need to instead check the individual characters. for (int i = 0; i < sentence.Length; i++) { if (sentence[i] == ‘a’ || sentence[i] == ‘e’ || sentence[i] == ‘i’ || sentence[i] == ‘o’ || sentence[i] == ‘u’) … Read more

Must declare the table variable @table

You can’t do this. You can’t pass the table name as a parameter the way you did: SqlCommand com = new SqlCommand(“insert into @table …”); … com.Parameters.AddWithValue(“@table”, tblname); You can do this instead: Console.WriteLine(“Enter table name:”); Console.Write(“>> “); string tblname = Console.ReadLine(); string sql = String.Format(“insert into {0} (time, date, pin) values … “, tblname); … Read more

Owin Self host & ASP .Net MVC

Update Now that ASP.NET Core is out there are a few ways to Self Host a web application. One option is to use an OWIN based web server such as Nowin. var host = new WebHostBuilder() .UseNowin() .UseContentRoot(Directory.GetCurrentDirectory()) .UseStartup<Startup>() .Build(); Alternatively, Kestrel has also been a popular choice for hosting ASP.NET Core applications. var host … Read more

Error message “CS5001 Program does not contain a static ‘Main’ method suitable for an entry point”

It means that you don’t have a suitable entry point for your application at the moment. That code will nearly work with C# 7.1, but you do need to explicitly enable C# 7.1 in your project file: <LangVersion>7.1</LangVersion> or more generally: <LangVersion>latest</LangVersion> You also need to rename MainAsync to Main. So for example: Program.cs: using … Read more