Best practice should be to not do this because it is prone to malicious SQL injection.
In any case, if you have control over the table variable, you should do it as @ madcow69 suggested, but I suggest adding delimiters, so you always have a valid delimited identifier (for example, if your table name is βorderβ or whatever another SQL reserved word).
string table = "City"; string query = string.format("Select * from [{0}]", table);
But what if table following ?:
string table = "City]; DROP DATABASE [YourDB";
source share