|
Yup..Sorry it is my mistake. You have already replayed it with the code block so it should help the poster now
Thanks
Laddie
Kindly rate if the answer was helpful
|
|
|
|
|
after included i cant find the COnfigurationManager also ...
system.configuration. only have
.ConfigurationSettings and
.ConfigurationException
|
|
|
|
|
Did you also add a "using System.Configurtion" to the file?
Scott.
—In just two days, tomorrow will be yesterday.
—Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines] [ Articles] [ Blog]
|
|
|
|
|
yes.. i had added.. the using System.Configuration but still don have the manager thing.
|
|
|
|
|
What does your code look like? Here is a simple example:
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string test = ConfigurationManager.AppSettings["test"];
}
}
}
Scott.
—In just two days, tomorrow will be yesterday.
—Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines] [ Articles] [ Blog]
|
|
|
|
|
i declare under this.. as global.. i do not want each function declare that..
namespace ttt
{
public class Dataaccess
{
private string sqlString = System.Configuration.ConfigurationSettings.AppSettings["connectionString"].ToString();
private SqlConnection cn;
|
|
|
|
|
First, please use the "code block" tags (<pre>) with code blocks like that to preserve the formatting.
Second, see my other resposne. You want your code to look something like this:
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
namespace DataAccessLayer
{
public class DataAccess
{
private string connectionString;
public DataAccess()
{
this.connectionString = ConfigurationManager.AppSettings["connectionString"];
}
public string ConnectionString
{
get
{
return this.connectionString;
}
}
}
}
Scott.
—In just two days, tomorrow will be yesterday.
—Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines] [ Articles] [ Blog]
|
|
|
|
|
thanks for the wonderful reply...
BUT .. i just cant get the $#&(#$ manager
Error 3 The name 'ConfigurationManager' does not exist in the current context
i had put the below script in the constructor as what u told..also added the using System.Configuration;
this.connectionString = ConfigurationManager.AppSettings["connectionString"];
but just no manager come out..
|
|
|
|
|
It still sounds like you haven't included the reference in the project. This is different than the "using" statement. In Visual Studio, expand the "References" folder of your project and make sure that you see "System.Configuration" listed. That should be all you need to do.
Scott.
—In just two days, tomorrow will be yesterday.
—Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines] [ Articles] [ Blog]
|
|
|
|
|
i ask from u, say me a website, content this web is some exercice program with explain solution type code. i am biginer programmer i want i progress in c# but i don't know how and which topic program , i write or i want write program but i don't know i write which topic program, i like help me i write bigginer program and ... ... .... ... ... after i write advance program. do u understand, my english very bad. i don't say u , write me web.
pliz help me, i need.
tnx
modified on Sunday, May 25, 2008 9:17 AM
|
|
|
|
|
I have no idea what you're really asking. But I would suggest:
1. Buy a book in your native language
2. Use google search for articles/content in your language so you can learn
|
|
|
|
|
Hello everyone,
I have the following scenario, and my question is whether I need to add lock or not?
In my scenario, there are two threads, one thread is accessing Dictionary instance Dic1, and the other thread is creating new Dictionary instance regularly in some interval, and the new Dictionary instance is named Dic2, and this thread will assign the instance pointed by Dic1 to Dic2, so that the new produced Dic2 could be processed by the first thread.
(Dic1 is like data consumer, and Dic2 is like data producer.)
1.
My question is whether I need lock for the operation for Dic1 of thread1, and Dic2 to Dic1 assignment operation in thread 2?
2.
Beyond using lock, are there any more efficient method? e.g. less locking? or not using lock at all?
Some pesudo code,
lock (Dic1)
{
Dic1.op1();
Dic1.op2();
Dic1.op3();
}
Dictionary Dic2 = new Dictionary();
Dic2.insert();
Dic2.insert();
Dic2.insert();
lock (Dic1)
{
Dic1 = Dic2;
}
thanks in advance,
George
|
|
|
|
|
I would use lock, if not you may be perfoming some operation with the data in Dic1 when you change it, who knows what could happen.
I think lock is fairly efficient though. Unless your operations take 5 minutes, and the second thread has to wait for the first to release the Dictionary.
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Thanks SK,
Generally, I agree with you. But what do you mean "your operations"? Could you clarify which operation in which thread do you mean please?
regards,
George
|
|
|
|
|
I meant where you did:
Dic1.op1();
Dic1.op2();
Dic1.op3();
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Thanks for your clarification, SK!
regards,
George
|
|
|
|
|
Hi George,
I would do that without any lock, but with careful programming:
1.
the dictionary producer (Thread2) does not need a lock, since Dic1=Dic2; is an
atomic operation. The statement either has been entirily executed, or it has not at all;
there is no way to have half of a reference replaced.
2.
The consumer wants a consistent dictionary, so make a local copy and use that throughout,
as in:
{
Dictionary localDic=Dic1;
localDic.op1();
localDic.op2();
localDic.op3();
}
|
|
|
|
|
So great, Luc!
1.
I have re-written the code as you suggested, here is my code, could you help to review whether it is your idea please?
{
Dictionary localDic=Dic1;
localDic.op1();
localDic.op2();
localDic.op3();
}
{
Dictionary Dic2 = new Dictionary();
Dic2.insert();
Dic2.insert();
Dic2.insert();
Dic1 = Dic2;
}
2.
Luc Pattyn wrote: Dic1=Dic2; is an
atomic operation.
Do you mean all reference assignment operation is atomic in C#? Any support documents?
regards,
George
|
|
|
|
|
Hi George,
1.
you don't need me to review a couple of lines, do you?
2.
In CLR assigning a reference is atomic (in the end what gets executed is an assembly
instruction that stores a 32-bit or 64-bit pointer value); it cannot be anything else,
what would be the purpose of half an assignment? You should be able to come to that
conclusion by reading the IL instruction set and documentation, I did that once,
but I have not done that as of late.
|
|
|
|
|
Hi Luc,
1.
Since English is not my native language, I want to make sure my understanding of your description is correct. So, reviewing the code is more about reviewing whether I understand your points.
Does my code correct?
2.
Looks great! But I see many code either using lock or using Interlocked.Exchange just to assign values for reference variable. Seems they do not know this feature.
regards,
George
|
|
|
|
|
Hi George,
1. your code is fine.
2.
you need locks or something similar when you NEED synchronisation, that is when you must
be sure about the order of things.
In your case, you don't care whether you use the old or new dictionary, the only thing
you want to avoid is using the old dictionary for half of the thread1 job and the new one
for the remainder.
If consistency is all you need, you don't need locks, just copy the reference at a well chosen
point.
|
|
|
|
|
Really great! Thanks Luc.
regards,
George
|
|
|
|
|
hi i would like to seperate my design page from validation. so i put the validation code in e.g validate.cs
design form
private void textboxInteger_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
validate.txtIntValidate(txtPhone.text)
}
in my validate class
class Validate
{
public bool txtIntValidate(string txt)
{
if (!Char.IsDigit(e.KeyChar) && e.KeyChar != (char)8)
{
e.Handled = true;
}
}
}
BUT in the validate.cs class .. how do i declare the e..
Error 3 The name 'e' does not exist in the current context
|
|
|
|
|
Good God.
e is not present because you have not passed it through. Even if you did, this method should be static, assuming this class should exist at all.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thank for the reply.. can u pls show some example to get all verification done is the class ? or at least guide me on declaring or passing the e
thanks
|
|
|
|