System.Data.SqlClient.SqlException (0x80131904) Error in C#

I am working on a database application with C# as frontend and MSSQL as backend. At some specific point of time, before the execution of a complex query, my business logic required to rebuilt an index, which I need to do from the C# application internally, without any user interface. but when I execute the specific SQL command as 

string strQuery = "ALTER INDEX ALL @tablename REBUILD PARTITION = @partition_number WITH (ONLINE = ON)";

I am getting this error-

*ERROR yourmessage Incorrect syntax near '@tablename'. [HouseKeep_VC.Program] [1]
System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near '@tablename'.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)

I am passing the @tablename as a parameter to the query along with the command object.