473,404 Members | 2,195 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Storing Enums in web.config

I have a module I have written that I'd like to use in a number of projets.
To save the various users having to tweak the code and recompile it, I'd
like to store all the parameters in the web.config.

This works fine apart from a series of eNums I have created.
When I try to assign myEnum = System.Config... I get an error message as I
cannot convert myEnum to a string.

So how do I do this ?

Nov 19 '05 #1
2 2827
Matt wrote:
When I try to assign myEnum = System.Config... I get an error message
as I cannot convert myEnum to a string.


Try something along these lines:

\\\
Dim myEnum as MyEnumType
myEnum = [Enum].Parse(GetType(MyEnumType), System.Config.whatever)
///

If you're using Option Strict, you'll need to DirectCast that to the
appropriate type:

\\\

myEnum = DirectCast([Enum].Parse(GetType(MyEnumType),
System.Config.whatever), MyEnumType)
///

Note that Enum.Parse() is case-sensitive.

Hope that helps,

--

(O)enone
Nov 19 '05 #2
Thanks, that did it !

Matt
"Oenone" <oe****@nowhere.com> wrote in message
news:eE**************@TK2MSFTNGP10.phx.gbl...
Matt wrote:
When I try to assign myEnum = System.Config... I get an error message
as I cannot convert myEnum to a string.


Try something along these lines:

\\\
Dim myEnum as MyEnumType
myEnum = [Enum].Parse(GetType(MyEnumType), System.Config.whatever)
///

If you're using Option Strict, you'll need to DirectCast that to the
appropriate type:

\\\

myEnum = DirectCast([Enum].Parse(GetType(MyEnumType),
System.Config.whatever), MyEnumType)
///

Note that Enum.Parse() is case-sensitive.

Hope that helps,

--

(O)enone

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: SpaceCowboy | last post by:
I recently got into a discussion with a co-worker about using enums across a dll interface. He wanted to use chars instead, argueing that depending on compiler settings the size of an enum could...
1
by: Ritu | last post by:
How to store connection strings in machine.config?What are the advantages of storing it in the machine.config file.Can u provide me with the information regarding accessibility of machine.config...
2
by: Shyam | last post by:
Hi, I wanted some advice on the following. All the users who log in to the system are created in the SQL Server. As I am not keen to store any user information on the web.config file for...
3
by: Kevin L | last post by:
I want to store database credentials in either the registry or a file. What is the easiest way to encrypt this information?
2
by: WB | last post by:
I have an app that will need to store hostorical data (path & filenames) in a combo box (so that the user doesn't have to type in the same data each time the app is restarted). Is it best to keep...
9
by: KarlM | last post by:
After reading some articles regarding confuguration data I'm a bit confused. Where is the right place for storing configuration data? - XML-files? - registry? - INI-files? (from a users point...
5
by: djc | last post by:
is it still customary to use web.config and global.asax to store connection strings? For example storing the string in web.config and using application start procedure in global.asax to declare a...
16
by: Jon Slaughter | last post by:
I'm declaring an enum and I would like to limit the scope I know that enum day2 {sun, mon, }; is equivalent to static const int sun = 0; static const int mon = 1;
11
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I have worked with application settings in VS2005 and C# for awhile, but usually with standard types. I have been trying to store a custom container/class/type in an application setting and I have...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.