Is it possible to dynamically set a static string during *class* Initialisation?

Posted by LonnieBest on Stack Overflow See other posts from Stack Overflow or by LonnieBest
Published on 2010-03-12T03:36:40Z Indexed on 2010/03/12 4:07 UTC
Read the original article Hit count: 242

Filed under:

I'm trying to dynamically create a connection string during compile time:

public static string ConnectionString
{
    get 
    {
        string connectionString = @"Data Source=" + myLibrary.common.GetExeDir() + @"\Database\db.sdf;";
        return connectionString;
    }
}

I keep running into type initialisation errors. I was trying to avoid having to set the connection string for all applications that user my code library. The location of the database is different for each project that uses the library. I have code that can determine the correction string, but was wanting run it during compile time. Is this even possible?

© Stack Overflow or respective owner

Related posts about c#