|
You can do that using methods in User32.dll. Here[^] is an example.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Use windows api function EnumWindows, http://msdn.microsoft.com/en-us/library/ms633497(VS.85).aspx
April
Comm100 - Leading Live Chat Software Provider
modified 27-May-14 8:52am.
|
|
|
|
|
string text = "A";
string newText = "Some text that wont appear, " + text == "A" ? "its A" : "its something else";
MessageBox.Show(newText);
Output : its something else
it wont show the first segment of newText plus the condition got reverse
string text = "A";
string newText = "Some text that wont appear, " + text != "A" ? "its A" : "its something else";
MessageBox.Show(newText);
Output : its A
All good for following
string text = "A";
string newText = "Some text that wont appear, " + (text == "A" ? "its A" : "its something else");
MessageBox.Show(newText);
Output : Some text that wont appear, its A
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
AFAIK, it is not a bug. '+' takes precedence over '==' hence you are getting those results. Actually, first statement will do this:
"Some text that wont appear, A" == "A" ? "its A" : "its something else"
Hence the result.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Brilliant !!!
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
It's also bad form to not properly scope your statement. It makes the code much easier to read:
string text = "A";
string newText = "Some text that wont appear, " + ((text == "A") ? "its A" : "its something else");
Next, you should use string.Format or a StringBuilder object when your doing something like this. It's more efficient in terms of memory use.
string text = "A";
string newText = string.Format("Some text that wont appear, {0}", (text == "A") ? "its A" : "its something else");
StringBuilder newText2 = new StringBuilder("");
newText2.AppendFormat("Some text that wont appear, {0}", (text == "A") ? "its A" : "its something else");
.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
|
|
|
|
|
To add to what danish said, it is always a good idea to enclose complex statements in parentheses, as it both enforces the precedence you want, and is easier to read.
I always use them for the "?" operator: (cond ? true : false). If nothing else, VS will highlight the beginning and end when the cursor is over the other, and CTRL+} will move from one to the other.
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
I'm learning WPF (finally). Just bought a book and started.
Things are going quite well and all the test application seem to work. I have only 1 problem I can't seem to find.
Everytime I want to change the name of the file and class from eg. Window1 to something more comprehensive I get an error in App.g.cs where he says that namespace "mynamespace" doesn't find the App object. For my tests I just deleted it, but since it is created by Visual Studio it will often overwrite it again.
I played around a little with XML namespaces in both the changed Window1.xaml and cs files as with the App.xaml and cs files. no avail (the book also uses standard Window1 naming so no help there).
I'm playing around on my home desktop with VS 2008 express (the free version) edition. I haven't tried yet on my work laptop.
thanks !
PS: just curious, my first impression is that WPF is a little 'forced' and is not really easy programming (xaml), am I alone in this?
|
|
|
|
|
Clean your solution and then try again.
V. wrote: PS: just curious, my first impression is that WPF is a little 'forced' and is not really easy programming (xaml), am I alone in this?
Using Expression Blend generally reduces some of this xaml work.
There are only 10 types of people in this world — those who understand binary, and those who don't. |
|
|
|
|
|
What do you mean exactly with "clean your solution" ?
thanks.
|
|
|
|
|
Hi All,
say i have these inputs strings:
string input_1 = " ABCD ";
string input_2 = " A BC D ";
string input_3 " A B C D ";
I want to convert these strings to the follows:
input_1 = " ABCD";
input_2 = " A BC D";
input_3 " A B C D";
basically remove all the blanks after the last letter, i know the string.TrimEnd() function in .Net can be used to achieve my requirement. Is there another way (without using string.TrimEnd() function) to achieve the same as String.TrimEnd() does?
Many thanks
|
|
|
|
|
Hello All
I have code to convert the first letter of the string to capital
Public sub Text2_Lost Focus (---)
s=text2.text
l=len(s)
s=lcase(s)
text=""
m=mid(s,1,1)
text2=text2 &""& ucase(m)
for i=2 to 1
m=mid(s,i,1)
a=asc(m)
if a=32 then
i=i+1
m=mid(s,i,1)
text2=text2 & "" & ucase(m)
end if
if a<>32 then
text2=text2 & lcase(m)
end if
next
end sub
Sagar Khairnar
(Jr.Software Developer)
|
|
|
|
|
You could write your own, but I don't see why you would unless this is homework...
|
|
|
|
|
This is not a homework, this is a question that i got during my previous interview
|
|
|
|
|
Without using trim - locate the last space in a string and then use substring to get the rest of the string.
There are only 10 types of people in this world — those who understand binary, and those who don't. |
|
|
|
|
|
Abhinav S wrote: Without using trim - locate the last space in a string and then use substring to get the rest of the string. And repeat...
Otherwise it just removes the final space, unlike TrimEnd which removes them all. Except it also removes trailing tab characters.
A better solution might be:
Regex.Replace(s, @"[\s]*$", "") Which does the lot for you.
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
The simplest solution is to use a regular expression:
Regex.Replace(inputString, @"[\s]*$", "")
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
this is the most efficient and accruate way, thanks very much.
|
|
|
|
|
you can do
input_3 = inputstr.Substring(0, inputstr.LastIndexOf(" "));
will give you the result you want.
theLizard
|
|
|
|
|
Unfortunately, that turns out not to be the case.
It will remove all data from the last occurance of a space to the end:
"A<space>B<space>C<space><space>" becomes "A<space>B<space>C<space>"
"A<space>B<space>C" becomes "A<space>B"
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
Oops, less haste,
If I could not use trim()
it should have been something like
<br />
<br />
if(string.LastIndexOf(" ") = string.Length)<br />
{<br />
string = string.Substring(0, string.Length-1);<br />
}<br />
<br />
But the answer from OriginalGriff seems to be the one, I have also learned.
theLizard
|
|
|
|
|
Make it a while loop and use a comparison operator rather than assignment.
|
|
|
|
|
oops (again, bugger) left out one of these = and yes a while would be appropriate if more than one at end of string.
I'm having an off day
theLizard
|
|
|
|
|
There are plenty of ways of doing this. Here is one:
You can make use of LastIndexOf and Replace method along with the Length property. Check the last index of the space and if it is equal to the length of the string, replace it with nothing. You can also use the Remove method instead of Replace.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Doesn't achieve what he asked for: it only removes the last space, not all trailing spaces.
All those who believe in psycho kinesis, raise my hand.
|
|
|
|