-
- Inline IF with no "else"
by Solrac Otr
- 6 Replies
- Last post
by Andrej Tozon
- Hi
I have a situation where I want to use an inline-IF, but I'm no sure if this is possible. Currently my code is like this:
if (myString.Length > 0) MyClass.MyProperty = myString;
I wanna use an inline-IF to make my code more readable, but I don't know if is possible to have an "empty" else.
I've tried the following:
1 - myString.Length > 0 MyClass.MyProperty = mySt
-
- right-associative operator compiler bug
by Dmitry Kolchev
- 12 Replies
- Last post
by James Curran
- Hello,
int a;
a = 1; a += a += a += a += 1; Console.WriteLine("Result1={0}", a);
a = 1; a += 1; a += a; a += a; a += a; Console.WriteLine("Result2={0}", a);
Before running code above I think the first and the second result will be the same. After running this code I've been surprised the results are different (Result1=5, Result2=16). In my point of view the correct
-
- Running windows application from MS visual studio 2005 Express edition
by BKassas
- 1 Replies
- Last post
by mwalts
- Hi
Say I've a sample "Hello World" application which has a button and on clicking it, it'll say: "Hello World". Can you explain me Why I can't see the appliction running It just runs without error and start and closed without seeing the main form. Do I need to adjust my C# enviroment.
Thanks
-
- Disabling screen saver for non-admins
by CLProgrammer2
- 5 Replies
- Last post
by H. Tony
- I wrote a program in C# that disables the screen saver for a certain amount of time by changing registry values. It works fine when ran by a machine admin but gets an permissions error if its ran by a normal user.
My first question is if I use the Windows API (SystemParametersInfo function, in user32.dll) would that be any differnt in allowing it to work for non-admin users
If not, i
-
- Why Cant? ((strTest == "Yes") ? "False" : "True")
by Solar9
- 3 Replies
- Last post
by John.Doe
- Why cant we use the following code
((strTest == "Yes") "False" : "True");
or
((strTest.ToString()) "False" : "True");
-
- Looking for AD users
by Sithlrd
- 1 Replies
- Last post
by TaylorMichaelL
- How can I return some info out of LDAP
I'm trying to look for my users (myself, first of all) on our domain controller. I can't seem to get the query to return any results. When I get to " if ( results . Count == 0)" it is always 0 .
What am I dong wrong here
DirectoryEntry de = new DirectoryEntry ();
de . Path = "LDAP://Maleficent/CN=Users;DC=cr
-
- Some 'Publish' questions.
by mshvw
- 0 Replies
- Last post
by mshvw
- Hello,
myApplication supports a helpfile 'help.chm'.
I publish it for CDRom and installed it running the 'setup.exe'.
My questions are:
(1) How can I add the 'help.chm' to my project
(2) How can I access this 'help.chm' from my installed Application
(3) How can I let the 'Publisher' make an additional entry in the startmenu in:
Start > Programs > Orga
-
- should i thread this?
by jss3426
- 4 Replies
- Last post
by jss3426
- i have a c# activex control hosted by unmanaged code.
The unamanged code upon instatiating my activex control calls a method SetUsers() for all users it finds in the database so say the db contains 100 users, the unamanged code calls SetUsers() a 100 times, api design not set by me as i cannot control nor inform the unmanaged code as to if i have completely set all my internal methods befor
-
- static method - Is there any workaround?
by TrevorW
- 14 Replies
- Last post
by TrevorW
- I think most know we cannot declare a static anything in an interface. However, let's say I have this:
public sealed class MyClass {
private MyClass(string someText) { m_someModifiedText = someText; }
private readonly static m_someModifiedText;
public static MyClass Create( string someText ) { string modifiedText= ModifyText(someText); return new MyClass(someText);
-
- Convert ASP.NET 1.1 Visual Studio 2003 to Visual Studio 2005, german umlaute
by WolfgangPurrer
- 1 Replies
- Last post
by Figo Fei - MSFT
- I'd like to convert a Asp.net 1.1 Applikation to Visual Studio 2005. The problem I have are some "umlaute" in the column names of the database and the datasets like in HTML - noation ü or ä The after no error's in the converting process the compile throws the following error: Error 1 Unable to convert input xml file content to a DataSet. Invalid 'name' attribute value
-
- filestream --need explanation
by rookie_rockie
- 4 Replies
- Last post
by Jeremy Filburn
- hi, i need some explanation.what is the difference between this: FileStream fStream = File.OpenWrite("theFile.txt"); and this: FileStream fStream = new FileStream("theFile.txt",FileMode.OpenOrCreate, FileAccess.Write,FileShare.None); can someone pls explain this to me. thanks in advance
-
- Functional Constraints?
by Kris Ganjam
- 10 Replies
- Last post
by Nimrand
- I want to be able to write a templatized function that works for string and char[] and my custom StringExtent which maintains a string as {char[], start and length}.
void f<T> (T t)
{
for (int i = 0; i < t.Length; i++) { char c = t[ i ]; }
}
Is there any way to get this to work in C# so that t[ i ] will get inlined My guess is that abstract base class or interf
-
- Using break with nested loops
by Stephen Fulwider
- 8 Replies
- Last post
by Paul Louth
- Hey, trying to write a pretty simple piece of code, seeing if there's a bit more elegant way to do this in C#. I'm trying to write a nested for loop, and have a single break statement to break out of the highest for loop. For instance, in Java this would be done like this: outerloop: for (int i=0; i<10; i++) for (int j=0; j<10; j++) if (condition_met) break outerloop; Do
-
- How to use the "Internet Explorer Administration Kit"
by Spyder.Snyper
- 3 Replies
- Last post
by Peter Ritchie
- So I'm working on a small app... (of course I am... what else would I be doing with C#... lol)
And it appears as though I need to use the "Internet Explorer Administration Kit" .
The website doesn't have too much on HOW to make use of it. In fact, I haven't been able to find ANYTHING on how to use it.
Maybe someone here can point me in the right direction
Al
-
- Is there any different between VB.net and C#.net other than Syntax?
by Fadi Nassri
- 13 Replies
- Last post
by sriesch
- we r about to start developing a new project
som of the team dont know C# and know Vb.net
if the syntax is the only different, No problem to use VB.net
can any one tell me if there is any different.
thank you
-
- Embedded statement cannot be a declaration or labeled statement
by pu132
- 4 Replies
- Last post
by pu132
- Why I really don't understand why this code is a compiler error:
if (true)
int i;
and this is legal:
if (true) {
int i;
}
It does the same thing. I understand why some argue that
return;
int i;
should be illegal (it is in Java but is only a warning in C#), but why won't compilers just listen to what the programmer is saying and do it At least this s
-
- change the resolution of the system by programatically
by Maheswari
- 3 Replies
- Last post
by Angel Kafazov
- My system is having 1152 * 864 pixel resolution environments. Here I am developing an application and its working fine.
Whereas in another machine is having 1024*758 pixel resolution. In this resolution some of the UI controls are invisible.
Can anyone help me to work my application in any resolution, with out doing anything manually
-
- what tools are available for resorting/reformatting/refactoring methods/properties in a class?
by Flip597
- 5 Replies
- Last post
by Ken Cooper
- Is there a tool available that will reformat/sort/reorder methods/properties/variables in a class/file
I used to use that type of tool with JBuilder and Eclipse (easy on the flames, I'm not proud of it neither :>>>>) and I would like to use something like that with Visual Studio 2005.
Thanks.
-
- where T : interface
by Thomas Danecker
- 11 Replies
- Last post
by Peter Ritchie
- Is there a way to specify that a generic type parameter must be an interface
You may ask why I need this constraint. As you may know, only interfaces and MarshalByRefObjects may be marshalled or intercepted. I'm developing my own RealProxy (for the typical logging-scenario) and I want to write a generic method which has an interface as parameter and returns a new __TransparentProxy.
-
- Int.TryParse
by DavidWhite
- 4 Replies
- Last post
by DavidWhite
- does int.tryparse only return true if the input is a whole number
-
- VS2005 With SP1 Install
by OmegaMan
- 5 Replies
- Last post
by OmegaMan
- I am looking at a possible reinstall of Visual Studio on a new PC (for me, not the PC) to replace an existing one. After perusing MSDN Subscriber Downloads I do not see a Studio 2005 version that includes SP1. Are there any plans to have a VS2005 with SP1 in the future
(Note updated title after the fact if anyone searches)
-
- How can i marshal a parameter from type 'pointer to pointer to struct'
by Geert Bogie
- 2 Replies
- Last post
by G.Bogie
- Hello,
I try to use the function 'C_GetFunctionList' (in DLL) within C#.
First some fragments out of the .h file in C++:
/ * CK_FUNCTION_LIST is a structure holding a Cryptoki spec
* version and pointers of appropriate types to all the
* Cryptoki functions */
/ * CK_FUNCTION_LIST is new for v2.0 */
typedef struct CK_FUNCTION_LIST CK_FUNCTION_LIST;
-
- options list in C# - using Switch in a do - while loop
by ToDieFor
- 8 Replies
- Last post
by ToDieFor
- I used to write programs in VB that would stack numbers for the options on a given form. Example: Status of an item, either Shipped, Cancelled, On Back Order, on Hold, etc. Each of these options would be given a number (Shipped = 1, Cancelled = 2, Back Order = 4, and so on). This number would be stored in the database, so something could be cancelled and on hold the number would be 10 (8 for on ho
-
- How to use c # to write shrinking algorithm?
by walking fish
- 14 Replies
- Last post
by walking fish
- Algorithm use c # language is described shrinking
Can write the code example
thanks
-
- Sorting a 2 dimensional list of places by distance
by emersonDub
- 1 Replies
- Last post
by Wiggly
- Hello, We're retrieving a load of place names and calculating the distance from a certain location. We wish to sort this list, closest place first and return the top 5 locations. Does anyone know how we'd go about this We were looking at multi dimensional lists, but sorting them is not very straight forward. Many thanks, David.