|
You need to build a dictionary of strings to strings. The key string is all lower case, with spaces and punctuation removed. This means you can't have duplicate entries, then you store the values in the collection, which remain nicely formatted.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
WOW!!
Do rate the reply, if it helps or even if it doesnot, because it helps the members to know, what solved the issue. Thanks.
|
|
|
|
|
Hello!
For that, use case for comparison i.e. change the strings to lower-case/upper-case before comparing both. You can use String.ToLower or String.ToUpper for that.
Hope that will be of some help!
Regards,
Adeel
Do rate the reply, if it helps or even if it doesnot, because it helps the members to know, what solved the issue. Thanks.
|
|
|
|
|
|
Use the overloaded version of String.Compare() that takes a bool parameter. That way, you won't be creating extra objects.
Cheers,
Vikram.
"I will put my new found knolage to good use" - Captain See Sharp.
"Every time Lotus Notes starts up, somewhere a puppy, a kitten, a lamb, and a baby seal are killed." - Gary Wheeler.
|
|
|
|
|
Yes, this will work so long as the case is the only thing that differs.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi,
i have two object of same class, suppose object name are class1 and class2.
and i have made class1 object and assign it to class2 object.if i do make
chages in class2 then it also affact to class2 object.
but i dont want this.means if i make any changes in class2 then it should not affact to class1 object.
so for thos what should i do.
please help.
amit
|
|
|
|
|
First, calling an object class1 or class2 is a bad idea.
Second, when you say obj1 = obj2; with reference types, you are not assigning one object to another, you are only assigning a reference to another.
amit_83 wrote: if i do make
chages in class2 then it also affact to class2 object.
Yes.
amit_83 wrote: but i dont want this.means if i make any changes in class2 then it should not affact to class1 object.
1. Don't assign the references.
2. If you absolutely must do something of the sort, consider implementing your Clone() method which creates a new object.
Cheers,
Vikram.
"I will put my new found knolage to good use" - Captain See Sharp.
"Every time Lotus Notes starts up, somewhere a puppy, a kitten, a lamb, and a baby seal are killed." - Gary Wheeler.
|
|
|
|
|
Well it's confusing at start but try to think of all "class"-objects as POINTERS or references (in C++).
You've got several possible solutions:
1.) Implement something like Clone (like proposed) - normaly you just add an copy-constructor so you can say MyClass Obj2 = new MyClass(Obj1) and use this in the Clone()-implementation - this way you can save one cast
2.) use struct instead of class - this will locate your objects in the local stack and copy the data instead of the reference when you say (obj2 = obj1)
3.) use the same data to construct the object 2 times with new
etc.
|
|
|
|
|
I have a Panel wherein i place textboxes dynamically. I have set AutoScroll property for the Panel to true. So when the size exceeds automatically Vertical Scroll bar appears.
I place dynamic textboxes in sequential order i.e one after the other row wise. I calculate the exact Location and place the control. This works fine.
The problem happens when i use the scroll bar to scroll down and then add few more TextBoxes. Now the location of the new added Text Box after scroll is not properly placed. Eventhough the calculation is the same. There is more gap between the previous and the next TextBox control. Why?
|
|
|
|
|
Hi,
First you should set the position of the Vertical Scroll into "0", then add the controls to the panel. Now it works fine.
this.panel1.VerticalScroll.Value = 0;
this.panel1.Controls.Add(objTextBox);
Regards,
Gopal.S
|
|
|
|
|
Thanks a lot for your help.
I tried setting the position of Vertical scroll to 0 and it worked.
Regards,
|
|
|
|
|
How to get value of one form to another???
ThanXXXXXXXXX in Advance!!!!
Truth Is The Simplest !!!!
modified on Wednesday, February 06, 2008 2:57:40 AM
|
|
|
|
|
Do you mean one FORM to another ? Use delegates ? There are other ways to do it, they are all wrong in comparison, with the possible exception of passing a value through a constructor. There is at least one good article on this on the site, try searching for it.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thank You!!!
Truth Is The Simplest !!!!
|
|
|
|
|
Can you please give me some guideline for using delegates???
Truth Is The Simplest !!!!
|
|
|
|
|
I have a question.. how do I get icons into C#. I'm talking about icons for toolbars in word editing programs.. Like the change color icon, left/center/right align icons, Bold, Italic, Underline icons.. I know they are stored on the computer somewhere, but where? Do I have attach these images to my program or can you use System.Drawing.Bitmap to display them since they are usually stored in the same folders on every computer using windows?
|
|
|
|
|
They'll be in a .dll (or various .dll's) somewhere, maybe in the MSOffice folder...
But your bitmap idea would work well... just take a screen shot and cut out the icons you want to use
.
Mark.
|
|
|
|
|
Hi,
I need to get a date out of a calendar control (set the CustomFormat to MM/dd/yy hh:mm tt), but when I call Convert.ToDateTime(dtpOrdStart.Value).ToString() I get the date and a random timestamp. Is there any way I can force it to 12:00:00 AM without having to go into the string and replace it myself?
thanx
|
|
|
|
|
Set the time portion of the DateTime ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Actually, you can't. The Hour property and others are read-only.
Cheers,
Vikram.
"I will put my new found knolage to good use" - Captain See Sharp.
"Every time Lotus Notes starts up, somewhere a puppy, a kitten, a lamb, and a baby seal are killed." - Gary Wheeler.
|
|
|
|
|
Sadly, it appears there is no way to directly do this. You can store the DateTime 's Year , Month , and Day fields in temporary variables and construct a new DateTime object with these.
Warning: I'm not sure, but using dt.AddHours(dt.Hours * (-1)) etc may cause problems with DST. The above method is, I think, the safest.
Cheers,
Vikram.
"I will put my new found knolage to good use" - Captain See Sharp.
"Every time Lotus Notes starts up, somewhere a puppy, a kitten, a lamb, and a baby seal are killed." - Gary Wheeler.
|
|
|
|
|
calendarControl.SelectedDate.Date
the .Date property of a DateTime is midnight on that date.
|
|
|
|
|
Excellent, 5'd.
Now how did I overlook that?
Cheers,
Vikram.
"I will put my new found knolage to good use" - Captain See Sharp.
"Every time Lotus Notes starts up, somewhere a puppy, a kitten, a lamb, and a baby seal are killed." - Gary Wheeler.
|
|
|
|
|
Hello, I need to write a program that has an output:
:
1. The total cost of all the items
2. The total sales tax, which is 8% of the total cost
The gratuity (tip). Most people tip either at the 15%, 20%, or 25% level, so tell the user what the 15% tip is, the 20% tip is, and the 25% tip is
I wrote everything but I do not know how to add a tip as a 15, 20 and 25 percent, so could someone help me out.
class Program
{
static void Main(string[] args)
{
// Price of items
const decimal PriceOnePizza = 0.95M;
const decimal PriceAPairOfHamburger = 2.95M;
const decimal PriceOneHotDog = 4.55M;
const decimal TaxRate = 0.08M; // 5.75%
// Customer personal infoirmation
// Unsigned numbers to represent cleaning items
uint NumberOfPizza, NumberOfHamburger, NumberOfHotDog;
// Each of these sub totals will be used for cleaning items
// Values used to process an order
decimal TotalOrder, TaxAmount, SalesTotal;
Console.WriteLine("-/- Arbys Restaurant -/-");
// Request customer information from the user
// Request the quantity of each category of items
Console.Write("Number of Pizza: ");
string strPizza = Console.ReadLine();
NumberOfPizza = uint.Parse(strPizza);
Console.Write("Number of Hamburger: ");
string strHamburger = Console.ReadLine();
NumberOfHamburger = uint.Parse(strHamburger);
Console.Write("Number of Dresses: ");
string strHotDog = Console.ReadLine();
NumberOfHotDog = uint.Parse(strHotDog);
// Perform the necessary calculations
// Calculate the "temporary" total of the order
// Calculate the tax amount using a constant rate
TaxAmount = TotalOrder * TaxRate;
// Add the tax amount to the total order
SalesTotal = TotalOrder + TaxAmount;
// Communicate the total to the user...
Console.Write("\nThe Total order is: ");
Console.WriteLine(SalesTotal);
// and request money for the order
// Display the receipt
Console.WriteLine("====================================");
Console.WriteLine("-/- Arbys Restaurant -/-");
Console.WriteLine("====================================");
Console.Write("Customer: ");
Console.WriteLine("------------------------------------");
Console.WriteLine("Item Type Qty Unit/Price Sub-Total");
Console.WriteLine("------------------------------------");
Console.Write("Shirts ");
Console.Write(NumberOfPizza);
Console.Write(" ");
Console.Write(PriceOnePizza);
Console.Write(" ");
Console.Write(NumberOfHamburger);
Console.Write(" ");
Console.Write(PriceAPairOfHamburger);
Console.Write(" ");
Console.Write(NumberOfHotDog);
Console.Write(" ");
Console.Write(PriceOneHotDog);
Console.Write(" ");
Console.Write("Total Order: ");
Console.WriteLine(TotalOrder);
Console.Write("Tax Rate: ");
Console.Write(TaxRate * 100);
Console.WriteLine('%');
Console.Write("Tax Amount: ");
Console.WriteLine(TaxAmount);
Console.Write("Total Amount: ");
Console.WriteLine(SalesTotal);
Console.WriteLine("------------------------------------");
Console.WriteLine("====================================");
}
}
}
|
|
|
|