|
ajay 2010 wrote:
i want to enter a number in between 4000 and 8000 and this number should contain the digit "2
I'm so excited for you. It's almost sexual this feeling. What are you doing later on? Your towering intellect is a real turn on. Oh no - I got wood."WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Pete O'Hanlon wrote: I got wood
More likely: woods[^] and too much mushrooms. Again.
BTW: here[^] is a useful application for it.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
modified on Friday, February 12, 2010 3:54 PM
|
|
|
|
|
Pete O'Hanlon wrote: I got wood
Be careful Pete, he might just try and track you down....Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
Pete O'Hanlon wrote: I'm so excited for you. It's almost sexual this feeling.
ROTFL x 1000000! Has he taken you up on your offer?Antoine de Saint-Exupery: Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
|
|
|
|
|
public void codez(int CodingNumber)
{
if (CodingNumber <= 8000)
{
throw new Exception("No");
}
if (CodingNumber == 4000)
{
throw new Exception("No");
}
if(CodingNumber == 4001)
{
throw new Exception("No");
}
if(CodingNumber == 4002)
{
return;
}
if (CodingNumber == 8000)
{
throw new Exception("No");
}
if (CodingNumber >= 8000)
{
throw new Exception("No");
}
}
The above code will work if you fill in the blank in the middle. Of course the code is abhorrent to anyone with eyes, but hopefully it will stop you from asking us to do your homework for you again. I could have done this on my Sinclair Spectrum, aged 10 years old in about ten minutes, so I fail to see why you haven't yet made an attempt to do this in the time you have repeatedly posted this question.Antoine de Saint-Exupery: Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
|
|
|
|
|
i have tried it. but i failed. that's why asked for help.i tried in this way..
int[] ajay=new int[3];
int x;
Console.WriteLine("enter the number");]
x=Convert.Int32(Console.Readline());
if ((ajay[0]==2)||(ajay[1]==2)||(ajay[2]==2)||(ajay[3]==2)
{
Console.writeline("valid");
}
else
{
Console.writeline("invalid");
}
|
|
|
|
|
ajay 2010 wrote: ,i consulted many people, but didn't get the answer.
You didn't get the answer you wanted. Instead, you got the correct answers. There's a huge difference between the two.
|
|
|
|
|
i have tried it. but i failed. that's why asked for help.i tried in this way..
int[] ajay=new int[3];
int x;
Console.WriteLine("enter the number");]
x=Convert.Int32(Console.Readline());
if ((ajay[0]==2)||(ajay[1]==2)||(ajay[2]==2)||(ajay[3]==2)
{
Console.writeline("valid");
}
else
{
Console.writeline("invalid");
}
|
|
|
|
|
May I suggest that you go back to your C# documentation and learn about integers, strings, arrays, conversion etc. I cannot see from your comments above how you ever managed to get to the interview stage, as it seems your basic knowledge is not there yet.
Here[^] is a useful link with some simple code samples to help your studies.txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
thanks for your suggestion...
dear..i tried it n got the solution...
int[] ajay=new int[4];
ajay[0]=2;
ajay[1]=2;
ajay[2]=2;
ajay[3]=2;
int x;
Console.WriteLine("enter the number");
x=Convert.ToInt32(Console.ReadLine());
x=x+1;
if (((x>4000)&&(x<8000))&&((ajay[0]==2)||(ajay[1]==2)||(ajay[2]==2)||(ajay[3]==2)))
{
Console.WriteLine("valid");
}
else
{
Console.WriteLine("invalid");
}
|
|
|
|
|
ajay 2010 wrote: i tried it n got the solution.
I am sorry but this is not a solution; your code does not solve the problem you set out in your orignal post. The first five lines of code serve no purpose except to ensure that whatever number you input between 4000 and 7998 will give the answer valid. So if you input 5555 it will say valid, even though 5555 does not contain a 2. As I said before, go back to your study guides and spend some more time learning about strings and character recognition, among other things.txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
ya what u told is true...
whether the logic i used in this program is correct or entirely i have to change....
|
|
|
|
|
Hi All,
Can we call a wcf service manually by using SOAP envelope, without adding a web reference?Jack Sparrow
--------------------------------------
Defeat is not the worst of failures. Not to have tried is the true failure.
|
|
|
|
|
No, why would you want to I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I don't know if you know the GEDCOM file format (.ged, genealogy file standard[^]), but I'm trying to read one and I want to put it in a listview. The following code opens a gedcom file, and saves the data (per person) to a treeview.
StreamReader reader = new StreamReader(@"test.ged");
string[] lines;
string file_content = reader.ReadToEnd();
lines = file_content.Split(Environment.NewLine.ToCharArray()[0]);
this.Text = lines.Length.ToString();
TreeNode currentperson = new TreeNode();
foreach(string line in lines)
{
string newline = line.Replace("\n", "");
newline = newline.Replace("\r", "");
try
{
if (newline[0].ToString() == "0")
{
newline = newline.Replace("@", "");
newline = newline.Replace("0", "");
newline = newline.Replace("INDI", "");
TreeNode newperson = new TreeNode(newline);
gedcomtree.Nodes.Add(newperson);
currentperson = newperson;
}
else
{
TreeNode currentnode = new TreeNode(newline);
currentperson.Nodes.Add(currentnode);
}
}
catch { }
}
Now my question is: How can i sort the elements in a persons' node aswell?
Example:
1 BIRT
2 DATE 01 FEB 1750
2 PLAC EDINBURGH
3 NOTE Old place.
1 DEAT
2 DATE 02 FEB 1800
etc.
Should make:
- BIRT
-- DATE 01 FEB 1750
-- PLAC EDINGBURGH
--- NOTE Old place.
- DEAT
-- DATE 02 FEB 1800
(In a treeview)
Could someone help me out on this one? Im trying to get this to work for 3 days now, and i'm still stuck
Thanks in advance,
ZaegraMotivation is the key to software development.
|
|
|
|
|
Zaegra wrote: string newline = line.Replace("\n", ""); newline = newline.Replace("\r", ""); try
{ if (newline[0].ToString() == "0") { //MessageBox.Show("newperson wotwot!"); newline = newline.Replace("@", ""); newline = newline.Replace("0", ""); newline = newline.Replace("INDI", ""); TreeNode newperson = new TreeNode(newline); gedcomtree.Nodes.Add(newperson); currentperson = newperson;
One easy way will be to move all the newline.Replace(); in a separte loop, sort the array of strings, and then add the Nodes from the sorted array.
|
|
|
|
|
When I pass an argument to a BackgroundWorker using RunWorkerAsync I can access that argument via the Argument property of DoWorkEventArgs in DoWork - is it possible to access that argument in the RunWorkerCompleted method?
|
|
|
|
|
Hi,
the Argument parameter is not passed automatically to the completion handler, however the latter gets two things: UserState and Result. AFAIK the UserState can be set as an optional parameter to ReportProgress(), whereas the Result is a member of DoworkEventArgs.
So it seems you have two ways to pass Argument to the completion handler, both requiring a little bit of code.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
UserState isn't passed to the completion handler - Result is but it seems a dreadfully clunky way to pass the argument. Still, if that's all there is I suppose I can just set the result as soon as DoWork starts so that there's a good chance it will make it through to the Completed handler.
|
|
|
|
|
Hmm, that doesn't work as Result is invalid if an exception was thrown during DoWork.
I think I will just store the object in a class variable and access that in both the DoWork and Completed events. I have seen conflicting versions at to how valid that is but it seems to work.
|
|
|
|
|
Interesting.
I do agree the Argument parameter should have been made available to all BGW event handlers.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
I agree too so I've coded up a quick CustomBackgroundWorker Tip/Trick here[^].
|
|
|
|
|
I trust you included proper attributions. Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
I'll edit it and link to this thread!
[Edit] Done [/Edit]
|
|
|
|
|
You could rewrite the entire component and code it as you wish. There is publicly available source code available here[^] that can be easily adapted.
The easiest way however would be to subclass the existing component and add a readonly property as below:
using System;
using System.ComponentModel;
using System.Windows.Forms;
public partial class FormMain : Form
{
public FormMain()
{
InitializeComponent();
Load += new EventHandler(Form1_Load);
}
void Form1_Load(object sender, EventArgs e)
{
CustomBackgroundWorker bgw = new CustomBackgroundWorker();
bgw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgw_RunWorkerCompleted);
bgw.RunWorkerAsync("Test");
}
private void bgw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
CustomBackgroundWorker bgw = sender as CustomBackgroundWorker;
if (bgw != null && bgw.Argument != null)
{
MessageBox.Show((string)bgw.Argument);
}
}
}
public class CustomBackgroundWorker : BackgroundWorker
{
private object argument;
public new void RunWorkerAsync(object argument)
{
this.argument = argument;
base.RunWorkerAsync(argument);
}
public object Argument
{
get { return argument; }
}
}
|
|
|
|