Wednesday, 21 August 2013

C# Setting a STATIC object -- conceptual

C# Setting a STATIC object -- conceptual

I had a crazy idea but I don't know the broader implications of this
[negative]... OR if anyone has a suggestion for improving this concept,
that would be awesome. Thanks Community!!!
public static class myCon
{
static myCon()
{
if (_con == null)
_con = new SqlConnection()
{
ConnectionString = "..."
// etc...
};
}
public static SqlConnection _con { get; private set; }
}
Only using a connection string as an example. NO, I would not suggest this
for an actual connection, this is just CONCEPT... I'm not that close to
the dried paint :)

No comments:

Post a Comment