tagged [constants]
Namespace constant in C#
Namespace constant in C# Is there any way to define a constant for an entire namespace, rather than just within a class? For example: Gives a compile error as follows: Expected class, delegate, enum, ...
- Modified
- 12 May at 14:46
How can I get a resource content from a static context?
How can I get a resource content from a static context? I want to read strings from an `xml` file before I do much of anything else like `setText` on widgets, so how can I do that without an activity ...
- Modified
- 23 Mar at 08:48
Declaring a hex constant in VB.NET
Declaring a hex constant in VB.NET How can I convert the following C# hexadecimal into a [VB.NET](http://en.wikipedia.org/wiki/Visual_Basic_.NET) hexadecimal? I tried the following, but it doesn't wor...
Type-inferring a constant in C#
Type-inferring a constant in C# In C#, the following type-inference works: But why can't the type be inferred when the variable is a constant? The following throws a compile-time exception: ``` const ...
- Modified
- 24 Jan at 19:33
Is there a runtime benefit to using const local variables?
Is there a runtime benefit to using const local variables? Outside of the ensuring that they cannot be changed (to the tune of a compiler error), does the JIT make any optimisations for const locals? ...
What is the point of a constant in C#
What is the point of a constant in C# Can anyone tell what is the point of a constant in C#? For example, what is the advantage of doing as opposed to I get that constants can't be changed, but then w...
Static Constants in C#
Static Constants in C# I have this code; Visual Studio tells me: `The constant 'Rapido.Constants.FrameworkName' cannot be marked static` How can I make this constant available from other classes witho...
Can I declare constant integers with a thousands separator in C#?
Can I declare constant integers with a thousands separator in C#? The [Cobra](http://cobra-language.com) programming language has a useful feature where you can use underscores in numeric literals to ...
How to have abstract and overriding constants in C#?
How to have abstract and overriding constants in C#? My code below won't compile. What am i doing wrong? I'm basically trying to have a public constant that is overridden in the base class. Thanks as ...
- Modified
- 9 Mar at 05:23
Why is there no Constant feature in Java?
Why is there no Constant feature in Java? I was trying to identify the reason behind constants in Java I have learned that Java allows us to declare constants by using `final` keyword. My question is ...
When, if ever, should we use const?
When, if ever, should we use const? `Const` is baked into the client code. `Readonly` isn't. But `const` is faster. May be only slightly though. The question is, is there ever any scenario where you s...
What is the difference between const int*, const int * const, and int const *?
What is the difference between const int*, const int * const, and int const *? I always mess up how to use `const int*`, `const int * const`, and `int const *` correctly. Is there a set of rules defin...
Why can't I have "public static const string S = "stuff"; in my Class?
Why can't I have "public static const string S = "stuff"; in my Class? When trying to compile my class I get an error: > The constant `'NamespaceName.ClassName.CONST_NAME'` cannot be marked static. a...
Receiving 'Expression being assigned must be constant' when it is
Receiving 'Expression being assigned must be constant' when it is Is there a way to use something like this: I think it would be more readable and less error prone than using something like: Are there...
How to declare a constant in Java?
How to declare a constant in Java? We always write: Question: 1. Is static final the only way to declare a constant in a class? 2. If I write public final int A = 0; instead, is A still a constant or...
Why can constants be implicitly converted while static readonly fields cannot?
Why can constants be implicitly converted while static readonly fields cannot? Given the below code, I wonder why `referenceValue = ConstantInt;` is valid while `referenceValue = StaticInt;` fails to ...
Difference between static and const variables
Difference between static and const variables what is the difference between "static" and "const" when it comes to declare global variables; which one is better (considering that these variables wont ...
Is there a difference between private const and private readonly variables in C#?
Is there a difference between private const and private readonly variables in C#? Is there a difference between having a `private const` variable or a `private static readonly` variable in C# (other t...
How to initialize const member variable in a class?
How to initialize const member variable in a class? ``` #include using namespace std; class T1 { const int t = 100; public: T1() { cout
Why Is `Export Default Const` invalid?
Why Is `Export Default Const` invalid? I see that the following is fine: However, this is incorrect: Yet this is fine: Can this be explained please why `const`
- Modified
- 28 Mar at 11:16
Differences Between vbLf, vbCrLf & vbCr Constants
Differences Between vbLf, vbCrLf & vbCr Constants I used constants like `vbLf` , `vbCrLf` & `vbCr` in a ; it produces same output in a MsgBox (Text "Hai" appears in a first paragraph and a word "Welco...
Using nested classes for constants?
Using nested classes for constants? What's wrong with using nested classes to group constants? Like so: ``` public static class Constants { public static class CategoryA { public const string ...
- Modified
- 31 May at 20:25