confused with class

  • Thread starter Thread starter nLL
  • Start date Start date
N

nLL

I'm a bit confused what to do about my statution below

i have below code

-------------------------------------------------------------------------------

public class NvUtils

{

public static string AgeCheckURL(string session_key)
{

return "http://domain.com/?session=" + session_key;
}

}

--------------------------------



what im confused about is that if i'm getting/setting AgeCheckURL in
correct way. for example when i call NvUtils.AgeCheckURL("SESSIONNNN")
different times with different values i always get first return. I know
it is due to sattic keyword and it only changes when i restart web
application. How im supposed to create the function that sets
AgeCheckURL with sesison input?



I know i can define is non static but then i would need to create
instance of NVUtils. Some how i dont want to create instance but access
it directly. I find it easier.
 
After serious thinking nLL wrote :
I'm a bit confused what to do about my statution below

i have below code

-------------------------------------------------------------------------------

public class NvUtils

{

public static string AgeCheckURL(string session_key)
{

return "http://domain.com/?session=" + session_key;
}

}

--------------------------------



what im confused about is that if i'm getting/setting AgeCheckURL in correct
way. for example when i call NvUtils.AgeCheckURL("SESSIONNNN") different
times with different values i always get first return. I know it is due to
sattic keyword and it only changes when i restart web application. How im
supposed to create the function that sets AgeCheckURL with sesison input?



I know i can define is non static but then i would need to create instance of
NVUtils. Some how i dont want to create instance but access it directly. I
find it easier.

If you call NvUtils.AgeCheckURL("SESSIONNNN") you should get
"http://domain.com/?session=SESSIONNNN".

When you call NvUtils.AgeCheckURL("SomethingElse") you should get
"http://domain.com/?session=SomethingElse".

The "static" doesn't mean that it will only return a single value, it
means that the method doesn't need/use any instance-values of the
containing class. That's why you don't need an instance of the class to
call the method.

Is the code you provided really enough to display the problem that you
are having? Or is it simplified too much and have you happened to
remove the problem-code?

What sort of "different values" were you talking about?

Hans Kesting
 
After serious thinking nLL wrote :
I'm a bit confused what to do about my statution below

i have below code

-------------------------------------------------------------------------------

public class NvUtils

{

public static string AgeCheckURL(string session_key)
{

return "http://domain.com/?session=" + session_key;
}

}

--------------------------------



what im confused about is that if i'm getting/setting AgeCheckURL in correct
way. for example when i call NvUtils.AgeCheckURL("SESSIONNNN") different
times with different values i always get first return. I know it is due to
sattic keyword and it only changes when i restart web application. How im
supposed to create the function that sets AgeCheckURL with sesison input?



I know i can define is non static but then i would need to create instance of
NVUtils. Some how i dont want to create instance but access it directly. I
find it easier.

If you call NvUtils.AgeCheckURL("SESSIONNNN") you should get
"http://domain.com/?session=SESSIONNNN".

When you call NvUtils.AgeCheckURL("SomethingElse") you should get
"http://domain.com/?session=SomethingElse".

The "static" doesn't mean that it will only return a single value, it
means that the method doesn't need/use any instance-values of the
containing class. That's why you don't need an instance of the class to
call the method.

Is the code you provided really enough to display the problem that you
are having? Or is it simplified too much and have you happened to
remove the problem-code?

What sort of "different values" were you talking about?

Hans Kesting
 
Code was extracted from one of my classes. This was my problem last
night and today i don't know what i have changed but it behaves as you
explained

i was doing some changes to other parts of the code not sure if they
effected the problem but being not sure what changed worries me more
than the problem.

Thanks
 
Code was extracted from one of my classes. This was my problem last
night and today i don't know what i have changed but it behaves as you
explained

i was doing some changes to other parts of the code not sure if they
effected the problem but being not sure what changed worries me more
than the problem.

Thanks
 
Back
Top