|
|
miggs70 wrote: I wasn't aware that I could separate things out with privates
They are called methods: private is a keyword that can go before the return type to tell the compiler that it should not be visible outside the class.
If you are trying to learn C# by looking at samples, you will take forever, and will have to work very hard. You will find it easier if you try a more structured method, such as a book. Have a look here: C# Yellow Book[^] it is the book they give first year students at Hull University and it's both not a bad start and free.
Do you have a copy of Visual Studio yet? If not, then Microsoft will give you a copy of the Express edition (which handles most things, and is well up to learning the language). See Here[^] for a copy. Warning - it's quite big!
And of course - CodeProject is more than willing to help!If Barbie is so popular, why do you have to buy her friends?
Eagles may soar, but weasels don't get sucked into jet engines.
If at first you don't succeed, destroy all evidence that you tried.
|
|
|
|
|
can any 1 send me the link that finds overlapping area of n rectangles
|
|
|
|
|
How can i change resource file that i use it in my project at runtime !
or
How to change Resource file Dynamically ?!
|
|
|
|
|
See the MSDN[^] pages on resource files.
Hint: try researching with Google/MSDN/CodeProject articles first.MVP 2010 - are they mad?
|
|
|
|
|
how to have :
System.ComponentModel.ComponentResourceManager res = new ComponentResourceManager(typeof("<code>C:\Resource.resx</code>"));
|
|
|
|
|
I don't think you can get what you have coded above; see here[^] for details. MVP 2010 - are they mad?
|
|
|
|
|
I am developing an application in c# , but the default window style on vista does not fit my requirement in term of look .
I want to have the application style like the default style in MFC application .
I am really concerned about the menustrip which I would like to be like the one in VLC player or any default MCF application
please How can I do it in c#. look around but nothing about it .
Application.EnableVisualStyle(); does not work
|
|
|
|
|
Is it ok in .Net 3.5 to change a property within a foreach loop? Does it still run the risk of producing unpredictable results? Also, will the potential results be noticeable or might it cause some type of slow, inconspicuous but nonetheless catastrophic error.
For example:
foreach(Employee janitor in EmployeesWithPayIncrease)
{
janitor.Salary += 5000;
}
Thanks for any help or information you can provide.
|
|
|
|
|
It is fine to change a property; the only thing you can't do is change the loop variable or the list itself.
So
foreach(Employee janitor in EmployeesWithPayIncrease)
{
janitor.Salary += 5000;
} is fine, but
foreach(Employee janitor in EmployeesWithPayIncrease)
{
janitor = new Employee();
} or
foreach(Employee janitor in EmployeesWithPayIncrease)
{
EmployeesWithPayIncrease.Remove(janitor);
} are not, as it would mean it would compromise the enumeration.If Barbie is so popular, why do you have to buy her friends?
Eagles may soar, but weasels don't get sucked into jet engines.
If at first you don't succeed, destroy all evidence that you tried.
|
|
|
|
|
I can think of ways to make the first piece of code fail as well
|
|
|
|
|
So can I! But I figure that if he is asking a basic (sensible, but basic) question like that, I didn't want to confuse him with custom comparisons, etc. I found it refreshing to be politely asked a sensible question If Barbie is so popular, why do you have to buy her friends?
Eagles may soar, but weasels don't get sucked into jet engines.
If at first you don't succeed, destroy all evidence that you tried.
|
|
|
|
|
True
I can also think of ways to make the other two pieces* of code work without (changing them, of course)
But it's not like that's going to happen in the real world a lot either
edit *: well ok only the last one, unless I'm allowed to cheat
|
|
|
|
|
Thanks for the information. I appreciate the answer.
However, I am curious: how could you make the first piece of code fail? Also, my code will work without unintended consequences, right?
|
|
|
|
|
BlitzPackage wrote: how could you make the first piece of code fail
The setter of that property could be changing the collection in some way
BlitzPackage wrote: Also, my code will work without unintended consequences, right?
Well that depends on what the property is doing..
|
|
|
|
|
You can't modify an object in a foreach loop like that. You have to loop differently (for , while , etc).45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Yes you can - provided the property you modify does not alter the comparison, or add / remove items from the collection. Increasing the salary would not be a problem. If Barbie is so popular, why do you have to buy her friends?
Eagles may soar, but weasels don't get sucked into jet engines.
If at first you don't succeed, destroy all evidence that you tried.
|
|
|
|
|
When a foreach is applied to a collection, C# will have the collection return an enumerator (I believe by calling a method, GetEnumerator). With the built in .Net types, those enumerators have logic in them that throw an exception if they detect that the list has been changed since the enumerator was created. They do this by taking a snaphot of the version number stored in the collection. Whenever a collection is modified, .Net increments this version number. And whenever an element is gotten from the enumerator, it checks it's version number against the collection it was created from.
The version number is only incremented for operations that change the structure of the list (reordering items, item removal, item additions, assigning items, and so on), not ones that change simple attributes of the list.
Also, most programmers are not aware that this version incrementing and checking must be done, so many custom collections will not throw an exception when the collection was modified in a foreach. For example, you could yourself create a custom collection that doesn't check if the collection was modified. Then no exception would be thrown when you modify the collection (add items, delete them, etc).
Whether or not modifying the collection during a foreach would cause an error (note that I didn't say "exception", I said "error") entirely depends on the collection.
|
|
|
|
|
How can i get all forms and folders of my project !(Name)
Note : I wanna the forms name and the subFolder of my project after i packaged my project! modified on Saturday, February 6, 2010 8:45 AM
|
|
|
|
|
I want to initialize the values of a multi dimension array. Instead of this:
string[,] arr = {{"charles","mary","moses"},{"erik","ann","grace"}};
I'd want to do this:
string[] class1 = new string[3];
string[] class2 = new string[3];
class1[0] = "charles";
class1[1] = "mary";
class1[2] = "moses";
class2[0] = "erik";
class2[1] = "ann";
class2[2] = "grace";
string[,] arr = {class1,class2};
This is not working. It gives the error:
Invalid rank specifier: expected ',' or ']'
In the last line. The reason is that i have the values for the multi dimension array in single dimension arrays. What can i do to load Multi-Dimension Values like the above from single dimension arrays?Wamuti: Any man can be an island, but islands to need water around them!
Edmund Burke: No one could make a greater mistake than he who did nothing because he could do only a little.
modified on Saturday, February 6, 2010 9:45 AM
|
|
|
|
|
A multidimensional array is not an array of array's, it's a single array with funky indexing.
If you change the declaration of arr to string[][] you could do what you want, but then of course it has become a jagged array (which just happens to accidentally be rectangular) instead of a multidimensional array.
If you really want a multidimensional array you could manually copy the arrays to their proper rows
|
|
|
|
|
Hello,
I wanna know If i declare function with same name, in interface and base class. and inherit this with Drived class. and call this function with drived obj.What Does it throws an error or not?
If not how its differentiates which function to call?
and how to call both the function?
EG:
<br />
Public Interface Iface<br />
{<br />
Void Display();<br />
}<br />
<br />
Public Class Base<br />
{<br />
Public Void Display()<br />
{<br />
Console.Readline("This is Base Class Method");<br />
} <br />
}<br />
<br />
Public Class Derived : Base, Iface<br />
{<br />
Public Void Display()<br />
{<br />
Console.Readline("This is Interface Method");<br />
} <br />
}<br />
<br />
Main()<br />
{<br />
Derived Dobj = new Derived(); <br />
Dobj.Display();<br />
Console.Readline();<br />
}<br />
Which function is called?
|
|
|
|
|
The interface will be called, Derived.Display() . After you fix the copiler-errors, since C# is case-sensitive I are Troll
|
|
|
|
|
And replace Console.Readline with Console.WriteLine!
Tch! The quality of code fragments is just getting worse and worse... If Barbie is so popular, why do you have to buy her friends?
Eagles may soar, but weasels don't get sucked into jet engines.
If at first you don't succeed, destroy all evidence that you tried.
|
|
|
|
|
Yeah, it's good to see a post with an actual piece of code in it I are Troll
|
|
|
|