TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ken H
NA
646
361.7k
How to use configuration files in C# class library?
Jun 26 2014 9:53 AM
Hi all,
I tried to set the initial value of a static field,But it does not pass compile.
How can I do this: initial value from Web.config or App.config.
My codes look like this:
Client:
using System;
using System.Text;
using Test;
namespace DEMO
{
class Client
{
static void Main(string[] args)
{
COMMON.Fun();
Console.ReadLine();
}
}
}
Class library:
using System;
using System.Text;
namespace Test
{
public static class COMMON // It will generate the DLL.
{
/*
Attempt to set the initial value of a static field.
Seek viable options?
*/
private static readonly string ConnString = System.Web.Configuration.WebConfigurationManager.
ConnectionStrings["SQLConnectionString"].ConnectionString;
static COMMON(){} //
Static
constructors
public static void Fun() {
Console.WriteLine("Connection String is:{0}",ConnString);
/*
TO DO SOMETHING ...
*/
}
}
}
Thanks.
Reply
Answers (
7
)
calender events in .net with c#
multiply two float number