|
I think that I didn't explain myself properly last night (my previous message was posted after midnight, so hopefully I get some slack !) in my code sample. Lookup(int foo) isn't needed, as lookup[foo] can be called inline, whereas Lookup2(int& foo) would have to be implemented at best. Also, internally Lookup(int foo) is one line of code whereas Lookup2(int& foo) has 3 AND a branching if statement (increasing cyclomatic complexity), both of these factors make my developer's Spider-senses tingle.
I agree this is subjective, as I have said in previous posts, there are good arguments for and against the nullable types we are discussing. (I was in the pro-camp for a fair while).
CCC solved so far: 2 (including a Hard One!)
|
|
|
|
|
You did a lot better job explaining yourself this time
Another appropriate use of nullables can be seen in a recent post:
Using LINQ to Calculate Basic Statistics[^] Here, null is used as a return for standard deviation if the set to calculate is invalid (e.g. null, empty, or < 2 elements). I think I tend to like that better than an out parameter and a boolean return value, and is certainly preferable to returning a valid double in an error case. I guess one could argue that a negative value would be ok (since std dev is >= 0), or an exception should be raised...
“To err is human, but to really foul things up you need a computer.”
-Paul Ehrlich
|
|
|
|
|
vtpdawg wrote: Here, null is used as a return for standard deviation if the set to calculate is invalid (e.g. null, empty, or < 2 elements).
The Mode method, this could be a valid use of null as a set like {1,2,3,4} doesn't have a single modal value (unlike {1,1,2,3,4}. Null isn't "zero" or an empty string or somesuch, it really denotes the abscence of anything. Though equally could implement the Method so that it throws an exception if the set doesn't have a mode. The author of the article states that he returns null as this is what Excel does. You pays your money, you takes your choice on this I think.
vtpdawg wrote: Here, null is used as a return for standard deviation if the set to calculate is invalid (e.g. null, empty, or < 2 elements).
This is a different matter, the code definately should throw an error, as you can't perform SD calcs on such sets.
I know that Exceptions ring alarm bells as the perception is that they have bad performance. This is indeed true if a debug build is made, however when a live build is made the performance is close to events (which is, after all what they are underneath).
vtpdawg wrote: I think I tend to like that better than an out parameter and a boolean return value, and is certainly preferable to returning a valid double in an error case.
Agreed, that would be an ugly solution, and as I have [hopefully successfuly] explained an unecessary one as it can be handled via exception.
CCC solved so far: 2 (including a Hard One!)
|
|
|
|
|
My biggest issue is that when you aggregate a field in SQL you need to deal with the potential null values, you end up with IsNull(Field,0) all over the place just to deal with them. I often put in a default of 0.
|
|
|
|
|
I agree wholeheartedly, this is the crux of the problem. The resultant cleaner code is a largeish benefit.
CCC solved so far: 2 (including a Hard One!)
|
|
|
|
|
I am using VS 2008 C#. on right clicking the text of code behind file. shows options like
Go to definitions, view designer Outlining etc. But my side, Outlining option is not coming. Can u please tell the reason behind this ?
|
|
|
|
|
How this is related to C#
|
|
|
|
|
abcurl wrote: shows options like
Go to definitions, view designer Outlining etc. But my side, Outlining option is not coming.
So which is it, Outlining is showing, or Outlining is not showing?
|
|
|
|
|
sir, it is not showing. can u please tell the reason ?
|
|
|
|
|
abcurl wrote: it is not showing. can u please tell the reason ?
Sorry, I cannot see why this would happen unless there is an option to disable it - which there is not, according to MSDN's help. I use VC# 2008 Express and it works fine there. I also tried Google and cannot find anything, so I would suggest you try one of the Microsoft forums.
|
|
|
|
|
Hi all,
See the bellow lines
string sTmp = "jacob martin (234) 890-3456 UsPhone comes -4533 UsPhone";
string patern = @"\(\d{3}\)\s\d{3}-\d{4}";
string sRpl = "XXXX";
string sResult = "jacob martin (234) 890-XXXX UsPhone comes -4533 UsPhone";
I want to replace the 4 digit elements with XXXX which is @"\(\d{3}\)\s\d{3}-\d{4}" in use formate.
See there is another 4 Digit string is there (4533) but it is not in the us pattern so i have to leave that.
can any one help me how to write Regular Expression for that
My Question is Simple
1.STmp is the input string
2.The Reg has to find the us patern (@"\(\d{3}\)\s\d{3}-\d{4}")
3.Replace the last 4 Digts as XXXX
4.Leave the another 4 Digits which is not as valid usphone no -4533
5.The ourput Replace String should be as "jacob martin (234) 890-XXXX UsPhone comes -4533 UsPhone"
Please some one help me to do
thanks in advance
|
|
|
|
|
Use capturing groups to keep a reference to the part of the pattern you want to keep.
string pattern = @"(\(\d{3}\)\s\d{3}-)\d{4}";
string sRpl = @"$1XXXX";
You can have as many groups as you like, each one being references by $1, $2, etc. You can also name the groups, but that seems like overkill for this case.
|
|
|
|
|
how do i resize a user control after adding it to other panel by event?
thanks.
modified 31-Dec-20 21:02pm.
|
|
|
|
|
Message Closed
modified 23-Nov-14 7:27am.
|
|
|
|
|
i have a form with a panel and a button, and i want that after clicking the button, a user control will brought to the panel in the origion form.
i tried to resize the user control manually like you said but the size doesn't change.
actually my user control is very small and the panel is big, i want that after pushing the button the user contol will be with the size of the split panel.
thanks.
modified 31-Dec-20 21:02pm.
|
|
|
|
|
Message Closed
modified 23-Nov-14 7:26am.
|
|
|
|
|
there is no dock property in the layout properties in the user control.
modified 31-Dec-20 21:02pm.
|
|
|
|
|
Message Closed
modified 23-Nov-14 7:26am.
|
|
|
|
|
even if i start over and adding a new user control i don't have a dock property for it.
modified 31-Dec-20 21:02pm.
|
|
|
|
|
Do you mean that when the user clicks the button you want them to be able to see and use your control? If so, then make use of the visible property.
If you are changing the size with the size property and it is not working, then you have a coding mistake somewhere.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Hi
This is Indresh I am new in C# I want to create a tree view of the form controls. With the each node I want to display a check box. By clicking on the check box I want to enable and disable the controls.
Hierarchy should be like this
Container form
child form1
control1
control2
child form2
control1
control2
child form3
control1
control2
Sorry for bad english
Tanks in advance
|
|
|
|
|
What is your queation?
Which part of this are you having problems with?
|
|
|
|
|
suppose your treeview name is treeview1.
use treeview1.nodes.add(your desired form name);
for child node :
treeview1.nodes[index].nodes.add(your control name);
from the treeview1 property true the value of checkbox property.
handle the afterselect event and check whither the
e.Node.Checked return true or false. Then take necessary action as you want
|
|
|
|
|
lm working on central bakery system and l want to fix the look of my forms is it possible to use CSS on windows application forms lm using C# on visual studio 2008
|
|
|
|
|
CSS cannot be used for windows forms (TTBOMK).
There is a company[^] selling something they claim is similar, but I've never investigated.
The best you can do is define a single form with the style you want, and derive from it, but that won't give you the button, text etc styles you probably want.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|