C# Frequently Asked Questions

The C# team posts answers to common questions

Ask a FAQ Question

Do you have a FAQ about:

  • The C# Language or compiler
  • The C# IDE
  • The Visual Studio debugger

Reply to this post, and your question will be added to our list to be answered. Of course, depending on the nature of your comment, and the volume we receive, we may not get to every question.

Note that if your question is not about C# specifically (if it is, for example, a Windows Forms question or a general question about the .NET Framework), it would be better to post that question to a newsgroup or web forum. Visit http://msdn.microsoft.com/vcsharp/community/ for a listing of related resources.

Thanks!

Published Saturday, March 06, 2004 2:47 PM by CSharpFAQ

Comments

 

Code/Tea/Etc... said:

March 6, 2004 8:42 PM
 

David Scott said:

I just have a couple of productivity questions regarding intellisense.

Is it possible when you type {, (, [, etc. to have the IDE automatically insert the corresponding }, ), ] etc.? Does this exist in VS.NET 2003? Am I just blind?

Would it be possible to have intellisense insert the beginning of the text when list values are the same?

Example:

If you type

System.AppD

and intellisense displays

System.AppDomain
System.AppDomainSetup
System.AppDomainUnloadedException

could the IDE automatically expand it to

System.AddDomain

or possibly if you just hit tab to select AppDomain leave the intellisense selection up if there are others that match?

March 6, 2004 6:25 PM
 

Arthur said:

If I send my program to a friend, he can't start it, even though he has the .NET framwork 1.1 installed, what have I done wrong?
March 6, 2004 6:33 PM
 

Phil said:

How can I do code injection?

I think I can use the remoting API but I'd like to know if there is a way to inform the compiler to inject code based on an attribute.

For example, we use a privilege based system. Every function needs a call to get the current user and ask whether or not it has the privilege X.

[RequiresPrivilege(AppPrivileges.SomePrivilege)]
public void function(){
...
}


I could then enforce that every public function also has a privilege attribute set to it.

I think I can do this at runtime with AppDomains but it feels like it's a big performance hit.

Will Whidbey solve my problem?

Thanks

PS I have a lot of questions regarding the IDE... let me know if they are appopriate here too.
March 6, 2004 6:42 PM
 

Chris Szurgot said:

Simple productivity question. Why doesn't C# intellisense expand enum values like VB.NET? I'm primarily a C# programmer, but I use VB.NET for some functions, and it's one thing I really miss.
March 6, 2004 8:46 PM
 

Omer van Kloeten said:

A. When, if at all, will there be a CSharpCodeParser implementation?
B. When, if at all, are you planning on creating a CodeDOM that is language specific, alongside the CLS one?
March 6, 2004 11:25 PM
 

Douglas Stockwell said:

Why does try/catch require curly braces even when there is only a single statement?

eg. The following is not permitted.

try
statement;
catch
statement;
March 7, 2004 12:14 AM
 

Luc Cluitmans said:

About C# 2.0:
why is there a 'new()' constraint for generics (requiring a no-arg constructor in the class), but not a constraint that requires presence of a particular argument signature for a constructor, e.g a constraint 'new(int, string)'. Having a no-arg constructor often means having partially initialized objects around, which in turn requires a check like 'is this object initialized?' in every method.

And related, is there any hope of being able to define a constraint requiring the constrained class to have a static method with a particular name and signature? (you cannot use interfaces for static method constraints, of course).
March 7, 2004 12:37 AM
 

Luc Cluitmans said:

Why doesn't the IDE (VS2003) allow me to reference an assembly with the extension *.exe? You can select an *.exe in the 'add reference' dialog (*.exe is in the open file dialog filter), but the next thing that happens is that it is refused. The worst part is that there is no reason to refuse it.

For those of you who are wondering why someone would ever want to import references from an EXE: you may want this ability when developing 'plugin' DLLs.
March 7, 2004 1:03 AM
 

Clint said:

Why doesn't the new Whidbey deployment features work with alternate build tools, such as NAnt?
March 7, 2004 2:27 AM
 

Wallym said:

I would really like to see Edit-N-Continue in C#. Yes, I can hear all the anti-ENC crowd starting to bubble up with displeasure at this horrible suggestion that will ruin development as we know it, but let me give you a real life situation that I have. I build large and complex applications. It literally takes several minutes to start the debugger and to get the application running. There is no great buzz-killer than to realize that the problem is because some property is being set to the wrong value or some method is being passed a wrong value or something else stupid. Why should I have to stop the debugger, change the value, restart the debugger, and then go back to the same location within the application? Before someone says, well just leave a web browser up and blah, blah, blah, what happens if the application is a Winforms application?
March 7, 2004 3:57 AM
 

W Poust said:

Why aren't there exquivalents for __FILE__ and __LINE__?
March 7, 2004 4:28 AM
 

Terence said:

If I have this...

string s = "this is a test";

why couldn't I do this in C#'s immediate window?

?s.IndexOf("this")

I will get "error: 's.IndexOf' does not exist" message. It works in VB.NET.

I have to wirte my own a generic method if I want to evaluate an expression that contains an object's function.



March 7, 2004 6:40 AM
 

Visual ActiveKent Sharkey .NET SE 3.11 said:

March 7, 2004 2:30 PM
 

Sean said:

When is the C# team going to implement edit and continue? Do I need to bug every programmer I work with at every contract I take to email the C# team to let them know that all of us want this feature? :-)

I've said it before and I'll say it again, "The MS Office team puts a billion and one features in their apps that I will probably never use all in the name of ROI and TCO, and yet one of the most important ROI and TCO features is being implemented by the VB.NET team, but not the C# team." Pretty please with a cherry on top: make Edit and Continue happen in C#!
March 7, 2004 11:43 AM
 

Christian Nagel's OneNotes said:

March 7, 2004 4:23 PM
 

Christian Nagel said:

Why is the same keyword used for the using statement and the using declaration?
March 7, 2004 1:28 PM
 

Len Weaver said:

The CLR seems to support co-variant return types. Will co-variant return types be supported in the next version of C#?
March 7, 2004 1:55 PM
 

Christoph Ruegg said:

Why doesn't C# support changing the return type of overriding methods to derived types, e.g.

class c1
{
public virtual c1 Negate() {..;}
}
class c2: c1
{
public override c2 Negate() {..;}
}
class c3: c2
{
public override c3 Negate() {..;}
}

Up to now I have to use workarounds like the following to support such behaviour (get's even more overhead in my case):

class c1
{
public c1 Negate() {return InnerNegate();}
protected c1 InnerNegate() {..;}
}
class c2: c1
{
public new c2 Negate() {..;}
protected override c1 InnerNegate() {return Negate();)
}
class c3: c2
{
public new c3 Negate() {..;}
protected override c1 InnerNegate() {return Negate();)
}
March 7, 2004 2:07 PM
 

Lockhead said:

************************************
If I have this...

string s = "this is a test";

why couldn't I do this in C#'s immediate window?

?s.IndexOf("this")

I will get "error: 's.IndexOf' does not exist" message. It works in VB.NET.

I have to wirte my own a generic method if I want to evaluate an expression that contains an object's function.
************************************

You get the annoying same behavior with .ToString() or .ToUpper() in the immediate window.

March 7, 2004 2:19 PM
 

dudu said:

C# Frequently Asked Questions From The C# team
March 7, 2004 7:48 PM
 

Anatoly Lubarsky said:

Why does not VS support ^shtml^ files - does not color the code there like in html files. In order to get it work I have to patch the registry.
March 7, 2004 5:28 PM
 

Ricky Datta said:

There should be such a function :

String.isnullorempty() =

(String.isnull() || String.isempty())

I do this a lot.

March 7, 2004 10:28 PM
 

Code/Tea/Etc... said:

March 8, 2004 4:17 AM
 

Pierre Greborio said:

When edit&continue in Visual C# ?
March 8, 2004 2:14 AM
 

satish said:

Why does c# requires 2bytes for storing array of booleans. However it takes 1 byte as a single site.

March 8, 2004 4:22 AM
 

Nicholas Schweitzer said:

I actually posted about this on my blog at http://schweitn.blogspot.com/2004_02_01_schweitn_archive.html#107782132911035587

The basic question is why doesn't C# support something similar to const reference parameters in C++? The problem lies in that there is no way for me as the caller of a method to know whether my argument to that method which is a reference type won't be changed. I think this is a huge shortcoming in C#/.NET ... and really kills programming safety, especially if someone is using a third party assembly where I can't look at the code and see what's happening. I want the compiler/CLR watching my back.
March 8, 2004 6:21 AM
 

RobC said:

Does C# have support for FTP connections like C++ does in the CFtpConnection and CInternetSession classes?
March 8, 2004 8:50 AM
 

Rob Chartier said:


Why does the IDE start to lock files after 15/20 projects in the one solution? How do we avoid this, and how do we fix this?

Why does the IDE basically start to break down after 30 projects? Locking files, losing intellisense, problems attaching to IIS (6) while debugging an asp.net app (need to reboot in order to fix this).

A fix would be to build some of the projects and make static references to their dll's. In many cases this is not realistic because to manage this would take up most of a developers day.

ps. I was recently talking with Habib Heydarian [habibh@microsoft.com] but he simply stopped returning emails and left my issues unanswered.

March 8, 2004 10:08 AM
 

Sayed Seliman said:

Why doesn't C# implements the "throws" clause as Java ?
How can I be sure that I capture all the possible exceptions throw by a class,or just when I have to capture one ??

Thanks.
March 8, 2004 11:55 AM
 

Kevin Westhead said:

Q1. Why doesn't C# support conditional tests as part of SEH, such as try..filter..catch in CIL or Try..Catch..When in VB?

Q2. Why doesn't C# provide a more flexible means of specifying interface implementation? E.g.

protected virtual void MyMethodCore() implements IMyInterface.MyMethodCore {...}

instead of

void IMyInterface.MyMethod() { MyMethodCore(); }

protected virtual void MyMethodCore() {...}
March 8, 2004 3:32 PM
 

Just a Developer said:

Okay check this out...

My DBA writes procs that take integers..if I have class member variable defined as an integer I can't assign an integer a null value obviously (ya ya value type, stored on the stack, I know I know)

But sometimes I have to pass SQL Server a null value, my variable is an int, the proc expects an int, but in SQL Server as you all know if you have a proc that takes an int you can just say

exec usp_SomeProc @MyInt = NULL and Sql server will completely treat the Int like a null..and ignore that parameter

thats all well and good...however you know the poor middle tier guy designing the classes can't pass an integer parameter with the value null...

i.e int x = null;//error , yeah we know

I know whats coming, use SqlTypes right...

But consider this situation where a class has a field called ID that is SqlInt32, but you get into a situation where you need to assign this field from a value in ViewState

so

SomeClass sc = new SomeClass();
sc.ID = (SqlInt32)ViewState["VendorID"];//Error!

Yessir...System.Data.SqlTypes.SqlInt32 is not serializable..so you will get the error:The type 'System.Data.SqlTypes.SqlInt32' must be marked as Serializable or have a TypeConverter other than ReferenceConverter to be put in viewstate.

Thats not cool..whats up with that...maybe the C# team isn't responsible, but could you ask the guys who are this question..why make it implement INullable and not ISerializable? It causes me much grief and I have to resort to cheap tricks..
March 8, 2004 5:53 PM
 

Robert Jacobson said:

Q: Why doesn't C# have a "handles" keyword?

In VB.Net, it's easy to hook up events using the "Handles" keyword. E.g.:

Private Sub TextBox_TextChanged(sender As Object, e As EventArgs) Handles currencyTextBox.TextChanged

In C#, the same is rather cumbersome -- using += and -= to manually subscribe/unsubscribe to the handlers.

I understand that the VB Handles keyword is really just syntactic sugar, but IMO it makes for more maintainable and readable code. += and -= seem like overkill for handling simple events.

Did the C# team consider adding a "handles" type keyword, and, if so, what was the justification for leaving it out? Are there plans to add a "handles" keyword in Whidbey or later versions of C#?
March 9, 2004 2:30 PM
 

Signs on the Sand said:

Interesting new blog at blogs.msdn.com - "C# Frequently Asked Questions", where the C# team posts answers to common C# questions. Subscribed. Why doesn't C# support default parameters? Why doesn't C# support multiple inheritance? Why doesn't C# support #define macros? Ask your question here....
March 10, 2004 7:33 AM
 

Philip Ant said:

Why are you all so great?
March 10, 2004 8:37 AM
 

LauraJ's Weblog said:

March 10, 2004 5:03 PM
 

Ahmed El-Shazly said:

Why C# support variable values for attributes (like [Foo(x)]) however; vb.net does not allow that?
March 11, 2004 3:07 AM
 

Peter D said:

Is there any way to see where the handles in use by a C# app are being used?

I have an app that grows to several thousand handles in use (as viewed in taskmgr) over the course of a day, but can't find the cause.
March 11, 2004 6:42 AM
 

Peter D said:

Add to the previous question.. Assume I can't (for a long list of silly political reasons I have no control over) "remotely debug" said application to get the same information..
March 11, 2004 6:47 AM
 

Rod Paddock said:

Why doesnt c# have a #INCLUDE directive ?
March 12, 2004 4:15 AM
 

William Robertson said:

(If my memory serves me well)
In c++ is was bad to do this:
for ( int i = 0 ; i < 10000 ; i++ )
{
int a = i;
}
as many, many ints would be created and fill up the stack space.

Is it okay to do that in c# or should I be coding it like:
int a;
for ( int i = 0 ; i < 10000 ; i++ )
{
a = i;
}
March 12, 2004 11:35 AM
 

Nazul's Weblog said:

March 15, 2004 7:18 PM
 

Nazul's Weblog said:

Un weblog con FAQs de C#.
March 15, 2004 7:20 PM
 

AJ said:

What future classes are being added to System.Collections? Can they be rewritten using generics and provide STL like usage?
March 15, 2004 8:52 PM
 

Chris Burrows .NET Blog said:

March 16, 2004 5:10 AM
 

Ron said:

What occurs internally when an ArrayList reaches its default capacity - 16; I noticed that the capacity gets doubled but what about the objects in the arraylist?

What occurs internally when you .Insert an item into the arraylist?

What is a good example of when to use the capacity value in the constructor ( new ArrayList(400) ) as opposed to using the default constructor (new ArrayList())

Thanking you,
-ron
March 16, 2004 2:31 PM
 

Dumky said:

I have read your "Calling Code Dynamically" which is very interesting, but I wish you would go into more details. What are the reasons for the performance differences?
Why are interface method calls slower than direct calls? Why are delegates even worse now, but on par in Whidbey?

Cheers,
Dumky
March 16, 2004 3:24 PM
 

Dumky said:

Can you give examples of uses of WeakReference besides caches?
Is there any guarantee that the pointer doesn't get collected between the call to IsAlive and getting the Target?
March 16, 2004 3:28 PM
 

Ron said:

I have officially gone crazy over using == and .Equals(). I have reached the point where I don't know the difference between them. Please help!
thanks,
-ron
March 16, 2004 5:54 PM
 

Omer van Kloeten said:

If class A defines a static member X and class B, which derives from class A, defines a static member with the same signature,
why am I asked to place the 'new' keyword on the definition in class B? Static members are supposed to be bound to the type, not to the instance. If I don't define a static member on B, why am I still able to perform B.X even though X was defined on A?
March 16, 2004 11:02 PM
 

Robert Pickering said:

Why can I give a structure a default constuctor? It would be great to be able to control what values the stuctures members take rather than having them assigned there default values.
March 17, 2004 12:27 AM
 

Dmitriy Zaslavskiy said:

Could you allow access to setter/getter directly to allow delegate creation.
For example:
class X
{
public string Foo { get; set; }
}

delegate string foo();
X x = new X();
new foo(x.Foo);
March 18, 2004 9:58 AM
 

Stephen Minton said:

Is C# getting Edit-and-Continue?
March 22, 2004 3:33 AM
 

Code/Tea/Etc... said:

March 24, 2004 1:49 PM
 

Code/Tea/Etc... said:

March 24, 2004 1:50 PM
 

Alex Moskalyuk said:

A question copied from
http://www.techinterviews.com/index.php?p=55

"How do you specify constructors in an interface?" Answer is "You cannot. C# does not allow constructor signatures to be specified in interface." I don’t know the reason why.
March 24, 2004 3:13 PM
 

raj said:

Hi,
I am c# developer.I want to know that in c# "plug-Compose" is
possible? "Plug-Compose" is different from "plug-play".

Any idea about "Module Adaptation" in c#.IF anyone can suggest me
links or examples.That would be gr8.

I would really appricate that.

Thanks a lot!!
Raj

March 24, 2004 4:11 PM
 

Scott B. said:

When using a the using statement as below, my form is not releasing the memory aquired when the form is shown.

The form only has some buttons and labels.

using (Wizard frmWizard = new Wizard())
{
frmWizard.Tag = log;
frmWizard.Show();
do
{
Application.DoEvents();
} while (frmWizard.Visible);
frmWizard.Tag = null;
}

thanks,

Scott
March 24, 2004 6:30 PM
 

Tim C. said:

Does assigning a variable to null at the end of a routine make any sense? I have inherited some code where this is done alot, and my opinion is that nothing is gained by assigning a variable to null right before it goes out of scope. Could we have some direction on this please?
March 25, 2004 8:11 AM
 

Kevin said:

Need to print a form out to a printer.
Used "Form".PrintForm
Scaling way out.
Can I scale? or use a "fit to page" so it automatically scales the form to an A4 sheet?
March 25, 2004 3:09 PM
 

S. Lee Odegard said:

accessibility: Does anybody except myself feel restricted with the Objective-C, C++ or Java inherited "accessibility" declarations (public, private, protected, internal, etc.). In general, if I have one class that needs special access to components in a second, do I have any alternative besides placing the first class in the same program file or re-declaring “public” the internals of the second class (which I may not want to be generally available)?
--S. Lee Odegard, leeo@amerion.com
March 25, 2004 4:57 PM
 

Kingsley Tagbo said:

What is the performance difference betwen using Static members and Instance members.

E.g. I have a class Admin and a member name GetUser()

What is the performance difference between

Admin.GetUser();

and

Admin admin = new Admin();

admin.GetUser();
March 26, 2004 6:57 AM
 

Ajit said:

In general web application(ASP.NET) scenario which of the variable will have the application scope for e.g if I read a properties file in a datastructure and keep it as a static variable. Is it the same as storing that variable in an application object.That means it is avaible till I stop IIS.
March 28, 2004 6:33 PM
 

Brian C. said:

I created a datalist with an edit link button following microsofts guide. Here is a code sample...

...<asp:datalist id="IssueDL" runat="server" OnUpdateCommand="IssueDL_OnUpdate" OnCancelCommand="IssueDL_OnCancelCommand" OnEditCommand="IssueDL_OnEditCommand">...

<asp:linkbutton id="onEditLB" runat="server" commandname="Edit">Edit Issue</asp:linkbutton>...

When I select the link button it appears to send two clicks to the server, hence my edit event handler is called twice. I have tested this with placing number labels on the page which get incremented by one if the edit event handler is fired. Clicking once on the link button increments the number label by two. I then set up a break point within the edit event handler and it gets hit it twice. If I trace the code through on the second trip I end with the following message dialog box:

"There is no source code for the current location".

I did a google on this and found this article on msdn:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/vxgrfnosourcecodeavailableforcurrentlocationdialogbox.asp

which mentions double-clicking a module. I am not double clicking the edit button but it clearly looks like two clicks are being sent. I looked at all of the system delagate event handlers and they all look right. Does anyone know how to resolve this? (I get the same behavoir with my update and cancel buttons).

Thanks
March 29, 2004 6:10 AM
 

Chris Ward said:

I have used Microsoft.Samples.WinForms.Extras to present a dialog for my User to browse to and select a folder.

This works fine, first time the User needs to browse the default path is set to "My Computer".

However, the User may need to browse to the same location a number of times and what I would like the dialog to do next time around therefore is to start at the folder previously browsed to. How can I "seed" the dialog to do this?

March 29, 2004 8:59 AM
 

Phil said:

I seem to remember somewhere someone made the comment that you should be careful when deciding to use static functions/fields in classes. I know that a lot of developers use static fields/methods as globally available fields/methods. Is this a good practice? What should you watch out for when using static fields/methods? Are static fields sometimes shared across AppDomains? Are there any threading issues with static fields/methods?
March 29, 2004 2:05 PM
 

Bob Thawley said:

How do I access a serial port using C#?
March 30, 2004 1:21 PM
 

David M. Kean said:

What advantages (such as speed), if any, are there to using readonly on private fields that only get assigned in the constructor?
March 30, 2004 6:26 PM
 

Roy Tang said:

In VB6 MTS was used to handle transactions. How are transactions carried out by C#?
March 31, 2004 1:11 AM
 

Sally Revell said:

How exactly does Visual Studio .NET integrate with NANT for doing builds? Any information would be appreciated.
March 31, 2004 2:22 AM
 

Sally Revell said:

How exactly does Visual Studio .NET integrate with NANT for doing builds? Any information would be appreciated.
March 31, 2004 2:22 AM
 

Ian M said:

Why C# does only support nameless indexers?
What about virtual constructors and class references? Is there any danger related to these features? I'm a Delphi programmer moving to C#, and I find class references and virtual constructors very useful to implement the factory pattern.
April 1, 2004 10:44 PM
 

chand said:

How to achieve the following in c#?

Public Shared Sub foo()
Static switch As Boolean
switch = not switch
End Sub

public Shared Sub bar()
Console.WriteLine(foo())
End Sub
April 2, 2004 1:16 AM
 

JG said:

In my organization, there's been quite a bit of back and forth regarding what is the "best" way to do string concatenation. Obviously, the "best" case will vary from situation to situation, but it's hard to determine a good guideline for when to switch methods. Can you please discuss the differences between, e.g.:

string a = "A";
string b = "B";

string c = a + b;

string c = string.concat(a,b);

StringBuilder sb = new StringBuilder();
sb.Append(a);
sb.Append(b);
string c = sb.ToString();

...as well as any additional concatenation methods you'd like to point out? Thanks!
April 2, 2004 7:17 AM
 

raji.n.e.george said:

i need your help for my project in the college it is about sending multimedia messegethrow mobile device by accessing to the database by dialing a special number.for more describtion send to me your agreement.thanks
April 2, 2004 2:04 PM
 

raji.n.e.george said:

i need your help for my project in the college it is about sending multimedia messegethrow mobile device by accessing to the database by dialing a special number.for more describtion send to me your agreement.thanks
my e-mail:tomy331107@yahoo.com
April 2, 2004 2:07 PM
 

Khurram said:

It would be nice if "in" keyword in C#, can behave also like TSQL's "in"

For example:

int i=1;
int[] goodValues=this.goodValues; //May be from DB
int[] badValues=this.badValues;
if (i in goodValues) && (!i in badValues)
{
//i is good, lets do something with it
}
April 3, 2004 6:36 AM
 

Rajesh said:

Why C# is consider Faster then any other .Net Language?
April 3, 2004 7:25 AM
 

Debapriya said:

give the namespaces of programming basics
April 5, 2004 11:42 PM
 

Inna said:

How can i check whether the property has keywords new, abstract, virtual, static, new in its declaration from CodeProperty?

There's no problem to get access modifiers, but what about the keywords?
April 5, 2004 11:51 PM
 

Chris S said:

How do you get text values (from textbox..) into numeric format(int or float) for computations. I have an old prg. (vcpp6) which used the atoi function from C Legacy. What do we use to replace this class of string conversion functions? I have looked into several textbooks and no examples of this were sited.
April 6, 2004 7:39 AM
 

James said:

How do you read in a jpeg as a x res * yres matrix of colors values in C# using the compact framework? Im trying to make a web service of something that used to run in matlab.
April 6, 2004 9:41 AM
 

Jay said:

public static void Main()
{
int i = 3;
int j = 3;
object o = i;
object o2 = j;

// Why is the output true? I thought boxing yielded different "boxes"
// and since System.Object.Equals is identity based the result would be false!
Console.WriteLine(o.Equals(o2));
}
April 6, 2004 4:44 PM
 

Terry Foster said:

I would really, really love this feature (and miss it from C++).
April 9, 2004 10:43 AM
 

Fredrik Normén said:

You have added a Nullable<T> struct to .Net version 2.0, but I would also like to see a Wrapper<T> class, that works just like the Nullabel<T> struct. If it is a class, it would give us the possibility to extend it. We could with a struct win performance because it will not be added to the heap, but is there another reason why you don't have created the Nullable<T> as a class?
April 9, 2004 2:10 PM
 

René Grob said:

Structs and boxing make everything more complicated. Structs are objects but in a way they are not. The way Java solves the boxing is less generic but has many advantages. E.g.: you can still add Integer objects.
April 12, 2004 8:44 AM
 

Nuno Saleiro said:

I am tring to generate a lot of random colors so I use the following function:

public void RandomColor(ref Color c)
{
Random R =new Random();
c=Color.FromArgb(R.Next(256),R.Next(256),R.Next(256));
return ;
}

when i run this from the I get always the same color. But when i use a breakpoint on the code, it works ok.

Any ideias ?
April 14, 2004 8:49 AM
 

Vikram Shenoy said:

This question is regarding the usage of Finalize() and Dispose(). How do u choose which one to use?? Dispose() clears up any managed and unmanaged resources anyway, so when do u have to actually use Finalize(). Finalize() has a extra overhead too as it has to be handled in a different way by the CLR. So how can u justify the usage of Finalize() in a situation?
April 14, 2004 3:19 PM
 

Sheva said:

what's the difference between asynchronous call and synchronous call?
I was pretty much confused when reading such words from Don Box's book <Essential.Net Volume.1>:
<quotes>
IAsyncResult has four members.The CompletedSynchronously property indicates whether or not execution took place during BeginInvoke.Although the CLR's asynchronous invocation plumbing will never do this, objects that implement asynchronous methods explicitly may elect to process an asynchronous request synchronously.
</quotes>
a couple of things confuse me here,for one thing,what actually plumbing is,and second,how to understand thoses words "process an asynchronous request synchronously".
April 14, 2004 9:46 PM
 

Barry Lovalvo said:

Why was DateTime created as a value type rather than a reference type? Making it a value type foreces everyone to find an alternative. Try Googling for "nullable DateTime C#".

Anyone who has ever worked with dates knows that they are frequently unassigned, so I assume that there's a well thought-out reason. The only thing that I've been able to come up with is the efficient memory allocation when used in arrays.
April 15, 2004 10:17 PM
 

Vasudevan said:

Why does C# doesn't allow to call an instance method inside a class declaration instead of method declaration?
April 16, 2004 2:17 AM
 

Sai said:

When are you going to release C# 2.0 ?
April 17, 2004 8:54 PM
 

SMS said:

can I write and deploy applications using visual C# standard edition professionaly? with out buying Visual Studio which is costly compared to C# alone
April 18, 2004 3:42 PM
 

sandy said:

I am running win89. I downloaded dotnetfx.exe
Douldle clicking asks if I want to install netframework1.1 It extaracts and says it needs to update windows installer momponents before setup can continue. ask if i want to procede. i say yes and it tells me that setup cannot contuinue . it cannote access windows installer components. setup cannot contine. how do i fix this??? please reply
doorknob@nt.net
April 19, 2004 10:59 AM
 

Michael Silk said:

Why doesn't c# have late-binding of methods ?

i.e. consider the code:
void process(string s){
Console.WriteLine("string called");
}
///
///
void process(object o){
Console.WriteLine("object called");
}
//
//
void testBinding(){
object obj = "string";
process(obj);
// result is "object called";
}

in java the result is "string called", why doesn't c# recognise the RTT of the object and adjust to call the appropriate method.
April 19, 2004 5:01 PM
 

interfacer said:

Why we can not define fields in an interface???
April 20, 2004 5:49 AM
 

Rafa® said:

Sometimes, when I need to assign optional fields to the database, these fields will receive null... Most of them are datetime types... So I pass a DateTime as a parameter, but since it is a Value Type, I can't assign null to the variable...

So I declare it as an object...
If the value will be passed, I instatiate it as an DateTime, and pass as a SqlParameter.. If don't, I just assign Convert.DbNull to the variable...

The first question here is, how good is that practice? The another is structurally, how the C# addresses that? Objects are Reference Types right? So, when I assign a Value Type, then the boxing comes in hand... But what the object variable really holds? The object becomes a value-type? How he's stored?

Thanks!
April 20, 2004 6:00 AM
 

Rafa® said:

Is there any equivalent to Vb.Net MyBase.New, to call the base class constructors?

Suppose a simple sample, I want to create an custom Exception, derived from the Exception Class... And I have my messages enumerated...

Acordling to the ErrorMessage I received, I load an Error string into Exception Message, and load some other custom fields a created for my Class...

In VB.Net I would do the following...

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

Public Enum ErrorMessages
Message1
Message2
End Enum

Public Class MyException
Inherits Exception

Public Sub New(message As ErrorMessages)
Select Case (message)
Case ErrorMessages.Message1
MyBase.New("This is the Error #1")
' Do some specific Login here
Case ErrorMessages.Message2
MyBase.New("This is the error #2")
' Do some specific Logic here
End Case
End Sub
End Class

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

Don't know how could I do this in C#... Because the only way I know to call the base constructor is overriding it, wich means that it'll have the same set of parameters of the base constructor...
Is there a way to reach that in C#?

Thanks..
Rafa®
April 20, 2004 6:15 AM
 

Shafqat Ahmed said:

According to a article (I think from Eric) it seems that Direct call is way too much faster than delegates, or even interface castign calls.

I have 2 questions
1. Why is interface casting so slow
eg
ISomething s = (ISomething) obj;
s.Execute();

2. What would be the performance of making a an abstract class and them implementing the abstract method. Then calling the method via the base class.
April 21, 2004 11:45 AM
 

Corey Kosak said:

A hashtable created the "normal" way, with the default constructor, will call the GetHashCode() and Equals() methods of the keys inserted into it.

However, a hashtable constructed with IHashCodeProvider and IComparer arguments puts more of a burden on the programmer. Specifically, the contract for IComparer.Compare(a,b) requires an ordering test rather than an equality test: it has to return a result indicating whether a is less than, equal to, or greater than b; not simply whether a equals b. There are many cases where a class can have a notion of equality but not of ordering.

Why this assymetry? Shouldn't the second parameter be something like an "IEqualProvider" rather than IComparer? The implementation of Hashtable obviously doesn't need an ordering test.
April 21, 2004 12:41 PM
 

Corey Kosak said:

I meant for this to be my subject line. :-)
April 21, 2004 12:42 PM
 

Sandy Pegram said:

I would like to know how to fix my color pixels on monitor and please don't tell me to follow the help because I have been through them steps so many times that I know them by heart what I really want to know is there a fix it program or does any one have any ideal on how to fix this problem because I have been on this for a month.The slider will not work to where I can change the pixels in my display area so please if any one can help I would be very greatful because I don't have the money to pay to have it fix the computer was gave to me so I am trying to fix it my self

Thank you
Sandy Pegram
April 21, 2004 11:11 PM
 

Sandy Pegram said:

I would like to know how to fix my color pixels on monitor and please don't tell me to follow the help because I have been through them steps so many times that I know them by heart what I really want to know is there a fix it program or does any one have any ideal on how to fix this problem because I have been on this for a month.The slider will not work to where I can change the pixels in my display area so please if any one can help I would be very greatful because I don't have the money to pay to have it fix the computer was gave to me so I am trying to fix it my self

Thank you
Sandy Pegram
April 21, 2004 11:13 PM
 

Sandy Pegram said:

I would like to know how to fix my color pixels on monitor and please don't tell me to follow the help because I have been through them steps so many times that I know them by heart what I really want to know is there a fix it program or does any one have any ideal on how to fix this problem because I have been on this for a month.The slider will not work to where I can change the pixels in my display area so please if any one can help I would be very greatful because I don't have the money to pay to have it fix the computer was gave to me so I am trying to fix it my self

Thank you
Sandy Pegram
April 21, 2004 11:13 PM
 

Stuart Gunter said:

I'm curious to know why the C# team left out the IsNumeric function from C#? This is a very commonly used function, and I would like to know the reason for omitting this from the C# language? It is catered for in VB.NET, but why not C#? Is there a significant reason?
April 21, 2004 11:32 PM
 

Dotnetjunky said:

Hi,

I would like to know the maximum limit of the number of elements I can add into a Hashtable before performance begins to degrade ? Specifically, I need to add around 150,000 elements into a Hashtable object. Would Hashtable still be able to handle that ?
April 22, 2004 10:11 PM
 

Waiman Li said:

I try to upgrade my VB6 program part by part. Could you send a sample to me on "how to create an ActiveX Control with C#?" Or just tell me how to do it.

Thank you,

Waiman
April 23, 2004 4:10 AM
 

daniella said:

why does an object finalize (or a destructor) method need to call it's base class finalizer?

thanks!
April 24, 2004 2:03 AM
 

Derek Powles said:

MSPress produce a software package "Visual C#.Net 2003 Standard Software" and separately a book and software package "Visual C#.Net De Luxe Learning Edition 2003" containing waht appears to be the above software plus the Visual C#,Net Step by Step book.
What do the two different software packages contain? How do they differ? The book package is priced lower than the software alone which makes more attractive.

Derek
April 25, 2004 12:42 PM
 

George Chen said:

Does Class WebClient Support Cookies and how to do?
Thanks
April 27, 2004 4:50 AM
 

thomas woelfer said:

how is one supposed to deal with float exception?

in c#, float operations don't throw exceptions. thats just like it has been /w c/c++ for ages.

thus, when developing math intensive apps, we used to turn on math exceptions so errors are emmediately visible when they happen. (for example, you _allways_ want a divide by zero or any other operation that results in #inf, #nan or suchliche to throw an exception).

this works great in c++/c rtl.

however, stuff in the bcl is using the 'c# does not throw exceptions' as a feature. for example, the font ctor throws an exception when exceptions are turned on.

iow: it has to be expected that bcl objects are using invalid float values as a means for normal operations.

this renders math exceptions useless for use in applications that rely heavily on math operations.

currently, when entering native c++ code from c# code, we turn exceptions on, turning they off when going back to managed code.

but how is one supposed to deal with this in managed c# code? checking every input data everywhere for validity simply is not an option when you have one gazillion lines of math code - thats what math exceptions are for after all: they are thrown in 'exceptional' situations that have not been tested for with other means. only - not whilst inside managed c#. what gives?

WM_QUERY
thomas woelfer

April 27, 2004 7:29 AM
 

John Hoebel said:

I find MS pages to be long on information and choices and short on organization.

Can you tell me the relationship between Visual Studio and Visual C#? I want to develop using C#. I went to MSDN and downloaded the runtime .net and the .net sdk 1.1. I want to use the IDE and looked on MSDN pages.

I hear Visual Studio and Visual C# but do not see relationship. I am guessing the Visual C# is a subset of Visual Studio, but I have no idea.

What do I need to develop .net application with .net IDE?

Thanks,
John
April 27, 2004 12:09 PM
 

Kevin Blakeley said:

Why do method signatures have to differ by arguments to create overloads? Why can't the return value make it unique?

Example

// Base Class
function bool Foo(int myVal)
{ }

// Derived Class that gets compile error
function int Foo(int myVal)
{}

// Derived Class with no error
function bool Foo(string myOtherVal)
{}
April 27, 2004 12:58 PM
 

Tilak said:

is there any limit for classes in a dll in .Net environment. If there is a limit then how many classes can be there in a .dll

April 28, 2004 12:24 AM
 

Sachin said:

How to customize PrintPreviewDialog in C# such that addition of a button, deliting existing control and changing functionality of existing control should be possible. Sample code will help me a lot
regards
April 28, 2004 12:34 AM
 

Jeff Gonzalez said:

I have a question about overriding Object.Equals() and Object.GetHashCode()

I posted about this at my blog (http://weblogs.asp.net/jgonzalez/archive/2004/04/22/118312.aspx) but I haven't gotten the answer I am looking for.

When I override the Equals method I get a compiler warning telling me I should consider overriding GetHashCode as well.

I understand that there are a few rules in respect to GetHashCode.

Rule #1 - If two objects of the same type represent the same value, the hash function must return the same constant value for either object.

Rule #2 - For the best performance, a hash function must generate a random based on instance fields (preferrably immutable fields)

Rule #3 - The hash function must return exactly the same value regardless of any changes that are made to the object.

I seems to me that Rule #1 and Rule #3 compete with each other. If my classes do not have immutable instance fields, should I still worry about overriding GetHashCode?

I have noticed some classes seem to implement a method for calculating a hashcode (System.Uri for example), but I am unclear on when/if I should consider overriding the GetHashCode method.
April 29, 2004 12:52 PM
 

Eric Wilson said:

Is there any difference between the following in terms of performance or generated IL?

class A
{
int i = 4;

public A()
{
}
}

and

class B
{
int i;

public B()
{
i = 4;
}
}
April 30, 2004 8:56 AM
 

Hagay Lupesko said:

I find the whole c# finalizer issue a bit weired:

The documentation I've read state clearly that the Finalize method of every object is called before it's de allocated, and that this invocation slows down the memory de allocation.

So, it seems like a good idea to implement IDisposable on every object, and within the Dispose method to call GC.SupressFinalize and that way we make the GC sweep faster.

But... microsoft doesn't recommend that, and it does seem silly to do such a thing explicitly.

Which leads to the final question - does the CLR calls the Finalize methods on objects even if Object.Finalize was not overriden ???

Thanks, Hagay.
May 3, 2004 1:49 AM
 

Ravikumar said:

How to implement LateBinding in c#?
May 4, 2004 2:01 AM
 

Faizal Jamal said:

How to capture a bitmap image from a webcam using C# ?
May 5, 2004 12:21 AM
 

faizal jamal said:

How to capture a bitmap image from a webcam using C# ?

May 5, 2004 12:23 AM
 

Kris said:

Is it possible ?
May 7, 2004 1:21 AM
 

Sankar said:


I want to append a stringbuilder object to an another string builder object.
Is that a way to do it other than
calling the stringbuilder.ToString() method.
May 7, 2004 4:33 AM
 

OmegaSupreme said:

How are type comparsions made in c#.
May 7, 2004 12:07 PM
 

Daniel Jin said:

<pre>

using System;

class Base
{

public virtual void Print()
{
Console.WriteLine( "Executing the base." );
}

}

class Derived : Base
{

private new void Print()
{
Console.WriteLine( "Executing the derived." );
base.Print();
}

public void Print2()
{
Print();
}

}

class MainApp
{

static void Main()
{

Derived obj = new Derived();
obj.Print();

Console.WriteLine( "" );

obj.Print2();

}

}

</pre>

now Derived have two different versions of Print, one can be called externally, one internally. should the compiler really allow this?
May 7, 2004 12:17 PM
 

Roger Heim said:

How do you debug WinForms control designers? I seem to have gotten it to work by loading the control library in an instance of the IDE, setting the library's debug mode to "Program" and setting the Start Application to devenv.exe and then using that second instance of the IDE to start a test harness for the control library.

Is there a better way to do it?
May 7, 2004 12:21 PM
 

Hagay Lupesko said:

Hi,

I've encountered a strange phenomena which appears to me as a bug:

I have an engine that uses a System.Threading.Timer to invoke a delegate every X minutes.

The code looks something like this:
TimerCallback callBack = new TimerCallback(Run); // run is obviously a method
analysisTimer = new Timer(callBack, null, 0, delay);
Console.ReadLine();

Everything works just fine when the code is build in Debug mode, but when the code is build in Release mode the delegate is invoked once only.

After creating debug symbols for the Release mode it looks like the timer class is optimized away...

The workaround solution I used was declaring the timer as static.

But obviously it's not very nice...

Any clue as to is this a bug, or what's wrong with the code ?

Thanks, Hagay.
May 11, 2004 1:53 AM
 

Da Gu said:

I can add a string to clipboard,but I cant add a file to clipboard.
My code:
Bitmap bmap = new Bitmap("c:\\mygraph.bmp");
//bmap.Save( @"c:\mygraph.bmp", ImageFormat.Jpeg );
this.pictureBox1.Image=bmap;
System.Windows.Forms.Clipboard.SetDataObject(this.pictureBox1.Image);
May 13, 2004 1:48 AM
 

Da Gu said:

I can add a string to clipboard,but I cant add a file to clipboard.
My code:
Bitmap bmap = new Bitmap("c:\\mygraph.bmp");
//bmap.Save( @"c:\mygraph.bmp", ImageFormat.Jpeg );
this.pictureBox1.Image=bmap;
System.Windows.Forms.Clipboard.SetDataObject(this.pictureBox1.Image);
May 13, 2004 1:51 AM
 

Da Gu said:

I can add a string to clipboard,but I cant add a file to clipboard.
My code:
Bitmap bmap = new Bitmap("c:\\mygraph.bmp");
//bmap.Save( @"c:\mygraph.bmp", ImageFormat.Jpeg );
this.pictureBox1.Image=bmap;
System.Windows.Forms.Clipboard.SetDataObject(this.pictureBox1.Image);
May 13, 2004 1:51 AM
 

Andrew Shapira said:

Why doesn't C# allow marking local variables with "const" (like C++,) or "readonly"?
May 14, 2004 7:18 PM
 

qhp said:

DOes someone use C# make a driver programe
May 15, 2004 7:25 AM
 

Stephen Montsaroff a-stmont@microsoft.com said:

How does the order of attribute specification effect attribute execution.

For instance, if I have two attributes which register information:
1. ProvideXXX
2. ProvideXXXFormats

and The ProvideXXX.Register uses information specified in ProvideXXXFormats (I am assuming that this is permitted).

How do I guarantee that PRovideXXXFormats is called prior to PRovideXXX?
May 17, 2004 10:37 AM
 

breeto@yahoo.com said:

For example...

interface IRecord
{
void Save();
void Delete();
static IRecord Read( int key );
}

The compiler complains about this...

The modifier 'static' is not valid for this item
May 18, 2004 9:13 AM
 

Colin said:

This drives me nuts. :)

ServiceProvider sp;
ArrayList sps;

// ...

foreach ( sp in sps ) // barf
{
}

Is it just to identify the type to cast the collection element to? To prevent you from changing the iteration variable inside the loop?
May 18, 2004 9:00 PM
 

Anon said:

from http://weblogs.asp.net/asmith/archive/2004/05/19/134781.aspx

"<i>So if "non virtual by default" is the right thing for c#... Then why isn’t “sealed by default” the right thing too?

It seems to me that if we are supposed to be testing extensibility points and purposefully allowing derivation and overriding for specific scenarios, then it seems to me that classes should be sealed by default, until we know that we acknowledge those scenarios.

Now, I’m not taking a stance here on the virt/nonvirt issue here. I really don’t care. But it just seems to me that “sealed by default” is the logical extension to the c# team’s points for their design, and I’m genuinely curious as to why they chose a different model at the class derivation level." </i>

May 19, 2004 5:00 AM
 

Björn Morén said:

C# is a great language and I'm happy to be able to use it. However it has a problem which it shares with many other similar languages (Java, C++, etc): the lack of elegant support for assigning multiple values to multiple variables at once. Especially is this evident when trying to return multiple values from methods, or swapping values between variables.

Simpler languges like Lua (www.lua.org) solves this in a very elegant way without the need for "out"-variables and similar. I think the Lua syntax is possible because the language is stack based, which to my knowledge IL is too.

C#:
a = BiteMe(x, y, out b);

Lua:
a, b = BiteMe(x, y);

C#:
temp = s
s = t
t = temp

Lua:
s, t = t, s;

Can this be incorporated in the C# language?
May 19, 2004 12:01 PM
 

Knarf said:

I'm currently a VB.net developer, and I'd like to begin my C# education. If you have any suggestions regarding literature that supports the self-taught. I'd appreciate some direction(s).

Thanks

Knarf
May 20, 2004 8:09 AM
 

Charlie Hensler said:

A number of times I've run into the situation where I wanted to provide two methods with identical parameters, but which return different types. A good example is a method that can optionally return a data reader or a data set.

I've read that the runtime itself actually supports overloads based on different return types, but C# doesn't implement this.

Thanks
charlie
May 20, 2004 9:56 AM
 

sun said:

How to make C# . net rs232 application run on pocket pc.
May 22, 2004 1:03 PM
 

Rahmatul Hamid said:

I'm confused about how to utilize Application Block in my C# based applications. I've not found any through sample which shows how to use all the tiers resides in the Application Block. Please, let me know where can I find a C# sample showing how to use Application Block step by step?
May 23, 2004 1:00 AM
 

Ronnie Lawson said:

Why isn't it anywhere near as simple to send to the Recycle bin as it is to do a plain File.Delete?
May 27, 2004 6:55 AM
 

Skerkles the Coding Clown said:

May 28, 2004 10:15 AM
 

Ashish Sheth said:

Why there is no 'throws' keyword in C# just like java?
In java a method can specify what exception it can throw using the 'throws' statment. This way the caller has to catch those exception or it can rethrow the exceptions to its caller. Why this functionality is not there in C#?
May 31, 2004 11:29 PM
 

Duncan Mackenzie said:

June 1, 2004 12:39 AM
 

elvis said:

I want to make a program to auto_exit windows2000 by c#.I can restart the machine,but i can not shutdown(require to press the power button).why?
June 1, 2004 9:48 PM
 

Mina said:

How can I connect C# to Database (mysql)? How can I work with the tables of the databank?
June 2, 2004 3:34 AM
 

dantitan said:

How can I reuse my exiting C++ classes from c#?
I don´t want to pack them into a dll, I only want reuse .cpp files.
I have found some articles about writing managed wrappers (using Managed Extensions for C++) for unmanaged C++ code, but they are not very clear, and don´t give real world examples using VS.NET.
June 2, 2004 4:12 AM
 

Brian Clifton said:

Will the C# language ever have support for C-style unions? Also, should structures really have to be instantiated with a "new" if they only contain data elements? They should be auto instantiated and be reference counted/auto destruct
June 2, 2004 11:40 PM
 

Vince Pacella said:

A friend and I were discussing method overloads and neither could explain why the return type isn't taken into consideration as a unique part of the signature other than it's just not.

For our curiosity, can you explain why that design decision was made?
June 4, 2004 10:06 PM
 

KPK said:

Hello:
In VB6, I have an app that uses createobject(). In this particular app, it comes in handy because one of our dlls provides enhanced functionality that not all customers want. As such we have two installs that we used. One only installs the standard edition of our app and the other installs the professional edition. If the user using the standard edition tries to access the extended feature (using its menu option), we display a messagebox telling them that this functionality currently exists in the professional edition of the app. Essentially we have an error handler that returns an error when we try to create an instance of the object. How can we accomplish this in C# without createobject?
June 8, 2004 8:43 AM
 

John said:

How would I call a button_Click() Event Handler from within my application (programatically). I want to treat it just like any other methed call, except I do not know how to pass the event handler the 2 required arguments.

June 11, 2004 7:06 AM
 

Mohammad Ramzan Hossain said:

What is the Differance between SQLDataCommand and SqlDataAdapter
June 12, 2004 4:33 AM
 

Vladimir Nesterovsky said:

By accident, I've collided with some behaviour of C# compiler, which I think is not very correct, but I'm looking forward to get rationale on this.

I have 3 projects: Project1, Project2, and Project2.

Project2 refers Project1, and
Project3 refers Project2.

These are the sources:

Project1:
---------
namespace Project1
{
public class A { }
}

Project2:
---------
namespace Project2
{
using Project1;

public class B { }

public class C
{
public static void Method(B b) {}
public static void Method(A a) {}
}
}

Project3:
---------

namespace Project3
{
using Project2;

public class D
{
public D()
{
B b = new B();

C.Method(b); // Error: The type 'Project1.A' is defined in an assembly that is not referenced. You must add a reference to assembly 'Project1'.
}
}
}

P.S. If you rename Method(B) to Method1(B) all works.
June 17, 2004 6:56 AM
 

arturo blumen said:

how do i save a report i created from a form to an excel aplication?
June 21, 2004 8:58 PM
 

shahbaz said:

how do i use msgbox in asp.net using c#
June 22, 2004 4:32 AM
 

Mike said:

IDE Question

Using which method was the .NET Control "Property Browser" (the property grid) embedded with the rest of Visual Studio .NET IDE?

Methods:
1) COM interop (the PropertyGrid was exposed as COM control)
2) MC++ (IJW)
3) other?
June 23, 2004 7:05 PM
 

Balaji Natesan said:

What is the difference between a static method and an instance method in terms of the memory allocation ?

Where Can i find some documentation as to what happens when a new is called on any object. As to how are the variables (static vs non-static) and method (static vs non-static) allocated in the heap ?

June 30, 2004 8:28 PM
 

Dejan Radovic said:

If I have a class hierarchy C1 -> C2 -> C3 and in C3 I override a method from C2 which in turn has overriden this method from C1, is there a way to call C1's version of the method? This would be something like base.base.MethodName() or C1.MethodName().
July 1, 2004 2:39 AM
 

Joe Williams said:

I currently have had an application NewProject written in Visual BASIC 6.0. I would like to create another utility program NewUtility and this time I would like to use C#. I would like to call this NewUtility application by selecting a menu item in NewProject application. Can I do this?

Basically, I would like to know if an existing VB application can call or activate a C# application. What are the requirements do I need to have in term of setting up the environment such as MS .NET framework, etc...

Thanks,
Joe Williams
July 1, 2004 6:50 AM
 

Javad said:

Hi and Help
I install CsGL in the way that you describe in (installing CsGL)
but in c# enviroment when i type
(using CsGL.) OpenGL disappear ??
July 5, 2004 9:46 PM
 

Omer van Kloeten said:

I'd love an answer for this:
http://weblogs.asp.net/okloeten/archive/2004/07/06/174196.aspx

Thanks in advance. :)
July 6, 2004 12:44 PM
 

jhon said:

how to edit the memory stream in vb.net
July 8, 2004 3:42 AM
 

Mohammad Kazem Sepehrifar said:

How we can implement "Multiple Inheritance" in C#?
July 9, 2004 3:21 PM
 

Hagay Lupesko said:

Hi,

I'd like to understand what's the difference between locking an instance of a collection (say, Hashtable) and locking the Hashtable.SyncRoot.

What's the difference, what is the SyncRoot used for, etc.

Thanks, Hagay.
July 11, 2004 12:41 AM
 

Pradeep Kumar said:

Hi,
I have a scenario where I am writing a property(using get and set) have to return a member of an object stored in an array of objects! The class user has to pass an index based on which a objects member is returned from the array.

How will the property be declared in C#?
July 12, 2004 8:52 PM
 

Chinna said:

How can we do similar to

CSting strtmp
strtmp.Format("%8.2f" , floatvalue)

and

strtmp = "322-343-3333"
strTmp.Remove('-')
this would return 3223433333
any direct function like this
July 13, 2004 11:57 AM
 

Ron Krauter said:

How can I perform a formatted input operation (extraction). In C++, we have the >> operator that does this.

Thanks.
July 16, 2004 9:12 AM
 

DaveF said:

I want to be able to use C# to develop tools that use API calls from propriatary sotware we use. DllImportAttribute seems to be the method used to declare the function. I've got the c header files for the functions and I beleive the following code is correct. But I get a NullReferenceException whenever I call the unmanaged function. Is there anyway I can determine what is causing the exception?

using System;
using System.Runtime.InteropServices;

namespace PiApi {

public class clsPiApi {

[DllImportAttribute("piapi32.dll", EntryPoint="pipt_findpoint", SetLastError=true,
CharSet=CharSet.Unicode, ExactSpelling=true,
CallingConvention=CallingConvention.StdCall )]
public static extern int findpoint([MarshalAsAttribute(UnmanagedType.LPStr)] string TagName ,
[MarshalAsAttribute(UnmanagedType.I4)] int pt);

public int getPoint(string TagName) {
int ptno = new int();
int retVal = new int();

try {
retVal = findpoint(TagName, ptno);
} catch(System.NullReferenceException e) {
System.Console.Write("Error " + e.Message + "\n\n");
}

if(retVal == 0){
return ptno;
} else {
return 0;
}
}

}
}
July 22, 2004 11:17 AM
 

anmy said:

???Web????image?????listbox??????????.
July 27, 2004 3:29 AM
 

travis said:

http://channel9.msdn.com/ShowPost.aspx?PostID=14932#14932
C# string vs. StringBuilder:
How many concatenations would it take for StringBuilder to be more useful than a plain old string?
July 27, 2004 12:06 PM
 

Ray Messier said:

I am currently on a project where I have to generate a huge number of XML packets. I am currently using the XmlValidatingReader to validate the xml in text fragments. The problem is speed -- let me explain. I am validating up to 2 million fragments in a loop at 1 time (yes). The fragments are never much over 2K in size, but since the reader doesn't allow (at least as far as I can tell) a way to clear the current fragment and load another, I have to create a new reader each pass thru the loop. This can't be the optimal way to do it. Anyone have any ideas on validating huge amounts of xml in a loop that won't take me several days to finish? Oh, to make matters worse the fragments are all different types (12 total types of xml packets). I was really hoping to do something like this -- but it don't work

XmlValidatingReader vr = new XmlValidatingReader(strXMLFragment, XmlNodeType.Document, context);
while (HIDEOUSLY_LONG_LOOP)
{
while (vr.Read()) {}
vr.Close();
strNextXMLFragment = GetNextXMLFragment();
vr.Open(strNextXMLFragment);
}
July 28, 2004 9:01 AM
 

bhavesh said:

how can i do advertisement of internet from speed.net and brand name is speed.net and other is cabble connection?
July 28, 2004 9:21 PM
 

Alex Shulman said:

How can I dynamically load .NET Class Librarry DLL without making it statically definition in My project
July 28, 2004 11:06 PM
 

Oskar Austegard said:

public static bool IsIn(object subject, params Type[] targetTypes)
{
foreach (Type target in targetTypes)
{
if (subject is target)
return true;
}
return false;
}
July 30, 2004 10:49 AM
 

Jaime said:

ok, i have two problems:

first: i'm trying to use an ObjectList for MovilePage at C# but when i'm tryin to catch the name of just a single field (Example: the item 1) i can't do it

second: also i'm trying to use a List but when i do the Bind(), all that appears in the browser is "System.Data.DataRowView" for each content
August 2, 2004 11:36 AM
 

Sachin Kalse said:

I am trying to develope a small RTF writer to generate project report at runtime, with a limited RTF writing capability using C#. As, RTF is one page document only, untill we intentionally put page breaks in it and Project report consists of number of pages. Thus, on what criteria it should be decided to insert page break? How to keep track of page's empty area before inserting anything?
OR
The next issue to overcome is to determine how to page-break text that is too long for one page.
Is there some way to identify exactly how many characters I can print before I run out of room in the current rectangle that defines the output, and do to a new page.
RTF specification 1.6 to 1.8 doesn't give any example regarding this issue.
I have tried on almost all question forums of C# but didn't get any hint.
Please guide.
August 2, 2004 6:19 PM
 

Sachin Kalse said:

If I insert an image in the RichTextBox at runtime, can I drag/move it inside the RichTextBox with the help of mouse, just like we can move any control on the form during design time.
Please guide
August 2, 2004 6:21 PM
 

Sachin Kalse said:

I am trying to make a customized PrintPreviewDialog using PrintPreviewControl. Can any one please explain how to change the

cursor only on the document that is displayed in the Preview control? We can use the cursor property of the PrintPreviewControl,

but that is not useful, as when you move in to the Preview control, the cursor changes even if you it is not on the document.
Is there any way to get the document area, so that we can check "MouseClick" event?
more over if two pages are displayed in the preview control, how to check which one is clicked?
Please guide.
August 2, 2004 6:24 PM
 

Sachin Kalse said:

I have divided a form in two parts, first half contains a tree view control, in the next half there is a panel control, on
that I draw some controlls like check box, radio button, combo box, numeric up down, etc. at runtime, corresponding
to the node click of the tree view control.
In this case how and where should I store the status of each control?
e.g.
If there is a check box and a combo box corresponding to the node 1 and I click node 2, before drawing the controlls
corresponding to node 2 on the panel, where should I save the status of the controls corresponding to node 1 such
that when I again click node 1 , I should again get the old status of the controlls corresponding to it.
please guide
August 2, 2004 7:08 PM
 

Sachin Kalse said:

In the tree view control with check boxes at each node, if I uncheck the parent node how to gray-out all checked children corresponding to that node?
Please guide
August 2, 2004 7:13 PM
 

aDeveloper said:

Why don't enums allow one to define methods (as well as other types of members) considering that they're just another ValueType like structs?
August 5, 2004 9:48 AM
 

sivaprasad said:

i am trying to fire an event in derived class.
which is declared public in base class.
this is a C# restruction ...
why it is so.....?
August 10, 2004 7:09 AM
 

Code/Tea/Etc. said:

August 25, 2004 6:17 AM
 

Rolando Ramirez Weblog @ DotNetJunkies said:

C# Frequently Asked Questions : How to send a question ?
September 17, 2004 10:51 AM
 

RebelGeekz said:

December 28, 2004 4:54 AM
 

Duncan Mackenzie .Net said:

Hey folks, I've been working with the C# Team and two great C# MVPs (Jon Skeet and Nicholas Paldino) to put together a 'live' C# FAQ. This FAQ is being run as a blog, hosted at

October 14, 2006 11:21 PM
 

C Frequently Asked Questions Ask a FAQ Question | Green Tea Fat Burner said:

June 9, 2009 3:01 PM
Anonymous comments are disabled

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker