|
Use a regular expression, or even better, Split and count your array.
To get the string length, just use the Length property.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
How about using some of the methods and properties of the String class. An example:
string s = "Nick Parker";
int len = s.Length;
Console.WriteLine("string:{0} length:{1}", s, len);
- Nick Parker My Blog | My Articles
|
|
|
|
|
public int pointVal(string input)
{
int count = input.Split(new char[] {' '}).Length - 1;
if (count <= 3) return 250;
if (4 ==count || 5 == count) return 500;
if (count >= 6) return 1000;
}
Grim (aka Toby) MCDBA, MCSD, MCP+SB
SELECT * FROM user WHERE clue IS NOT NULL
GO
(0 row(s) affected)
|
|
|
|
|
Hello I have a technical question:
I am working in a project.my code is in a seperate DLL ,separate class.The point is it works correctly on most of the inputs.However on some inputsit gives the following alert box message:
An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll
Additional information: Index was out of range. Must be non-negative and less than the size of the collection.
I know this type of exception,but the problem is when i place a breakpoint (anywhere in the class,even in the constructor)to start debugging,in the debug mode itwould give the following message:
There is no source code available for the current location.
SHow dissassembly automatically
and ofcourse the cursor wont be standing on any line,to allow me to start debugging.
Does this mean that the first exception occured in another class or DLL which is not related to my code?
Thanks a million
|
|
|
|
|
hi,
your Wrote :'System.ArgumentOutOfRangeException' and 'ndex was out of range. Must be non-negative and less than the size of the collection' - > Please check your collection , whether you are not trying to access which is not there in the list.
You Wrote :Does this mean that the first exception occured in another class or DLL which is not related to my code?
Here you are assumption may correct. Try to use proper error handling methods in your .dlls. Otherwise try to throw exception to your base.
//code in dll file.
public void add()
try
{
//something
}
catch(Exception Ex)
{
throw Ex;
}
//code in your application.
try
{
dll_instance.Add();
}
catch(Exception Ex)
{
Messagebox.show(Ex.StachTrace.ToSting());
}
//Here you will get information from where error occures.
Sreejith Nair
[ My Articles ]
|
|
|
|
|
You may be able to step into the code of the separate DLL if the debug symbols are available for it.
Is the dll raising the exception written in managed code (C#, VB.Net etc)? If so, compile it in debug mode and reset the reference in the calling application. You should be able to then either set a breakpoint immediately before the call raising the exception and "step into" the code that's having trouble, or just set the debug feature to break into the debugger on all exceptions.
The previous poster was correct, however, the error you're seeing is because somewhere you've got code indexing past the end of an array/collection. This commonly happens for a couple of reasons:
1. Developer forgets that arrays are 0-based (so the index of the last element is Array.Length - 1)
2. The collection is being shortened (items are being removed) within the code while an iterative loop moves from lowest to highest index (e.g. 0-10). Since each removal essentially re-indexes the collection, eventually an index will be selected that is past the end of the array.
Hope this helps
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
Hi!
I'm looking for two controls, one to do Gantt diagrams and another one to implement an Calendar in wich I could post dates (like outlook for example). Does anyone know any free control implementing one (or both) of this funcitonalities?
I'm developping a Windows Forms application.
Thank you!
Jordi
PS - If I don't find it I will try to develop them. If I do it i'll post them in this fabulous website!
"Catalonia is not Spain"
|
|
|
|
|
You are looking for some thing like 'Planner'. Microsoft Project Planner ?
Sreejith Nair
[ My Articles ]
|
|
|
|
|
Yes, something like that but I don't look for a program, I look for a control to be added to my .NET application. Do you know any free control like this? I don't need an espectacular control, a simple one implementing Gantt diagrams or a calendar would be perfect.
Thanks!
"Catalonia is not Spain"
|
|
|
|
|
|
|
I look for a Calendar in wich i could implement and Scheduler. I would like to be able to insert some text in a specific date. It is not possible in MonthCalendar, isn't it? I look for something like Outlook.
Thanks anyway!
"Catalonia is not Spain"
|
|
|
|
|
look at www.infragistics.com
|
|
|
|
|
Hello,
What is the CultureInfo format string for a decimal that I want to show with no trailing zeros?
1.000 is formatted as 1
1.100 is formatted as 1.1
1.010 is formatted as 1.01
1.001 is formatted as 1.001
Thanks in advance,
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
If you call the ToString method of your decimal the trailing zeros are automatically trimmed. To ensure the decimal separator is always a point provide a CultureInfo that uses this decimal separator, e.g.
CultureInfo culture = new CultureInfo("en-US");
decimal x = new decimal(1.010);
MessageBox.Show(x.ToString(culture));
www.troschuetz.de
|
|
|
|
|
Thanks for your reply, but that didn't solve my problem.
I have a DataGrid control, to which I assign a DataGridTableStyle . One of its DataGridTextBoxColumn s is supposed to display a quantity of the product sold. In most cases, you only can get products in multiples of 1 (bottles of water) but in rare cases (oil for example, the app is for a car wash) it can be sold in fractions.
The data field from the MSDE database is a decimal with scale 4, so the DataGrid always displays the value with 4 decimals. I'm trying to set the DataGridTextBoxColumn 's Format property so it trims trailing zeros, but I can't find how. I've set it successfully for other columns (currency) but not for this one.
Any more ideas?
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
I'm trying to do something like this:
OpenFileDialog xOpenFileDlg = new OpenFileDialog();
xOpenFileDlg.Filter = "All Images|*.png,*.bmp,*.jpg,*.gif,*.tif";
xOpenFileDlg.ShowDialog();
(i.e. make it show all the png, bmp, jpg, gif and tif files, but not anything else) - but I can't work out the proper syntax for the wildcard
can anyone help?
--
Help me! I'm turning into a grapefruit!
Phoenix Paint - back from DPaint's ashes!
|
|
|
|
|
nevermind - got it, semicolons
xOpenFileDlg.Filter = "All Images|*.png;*.bmp;*.jpg;*.gif;*.tif";
--
Help me! I'm turning into a grapefruit!
Phoenix Paint - back from DPaint's ashes!
|
|
|
|
|
1)how can I make properities or attributes in order(NOT SORT-LIKE) or take control them in order?
For example:
public string List
{
get { return m_strList; }
set { m_strList = value; }
}
public string List2
{
get { return m_strList2; }
set { m_strList2 = value; }
}
public string List3
{
get { return m_strList3; }
set { m_strList3 = value; }
}
it went like this:
List1
List3
List2
I dont know how did it do that.
I want to go like this
List2
List1
List3
can you tell me how to control these properties?
2)I am having struggle with changing color with using readonly
I am using those codes:
[ReadOnly(true)]
public string List
{
get { return m_strList; }
set { m_strList = value; }
}
I wanted to prevent the user to change the List but it changed the color black to light gray bec of readonly changed its color text. I tried to changed its text color(like ViewForeColor). No luck. what are your suggestions that how to change its text color?
Thanks in advance
|
|
|
|
|
how can i get the handle of popup form in my main form before it can get visible?...i want to destroy this form before user can see it...
|
|
|
|
|
In short, you can't. Also, it's very poor practice. You can get the handle, but it takes some searching with a couple of API functions. While this searching is going on, the window will have shown itself. After you get the handle, then you can send the WM_CLOSE message to it. But, there's no telling what will happen when you do this.
What are you trying to do? What window are you trying to supress? If it's part of your app, why would you want to quash a window that you put up?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
infact i'm using a tool on my form and it is trial but before loading this tool it shows a dialogbox and i want to close it...
|
|
|
|
|
You're kidding me, right? You want help suppressing a dialog that says that this is a trail version? Pay the author for the control and get the version that doesn't have that dialog box.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
if i had money i would buy it,but i dont
|
|
|
|
|
Don't expect help stealing someone elses work!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|