|
The only reason to use recursion is if it's a homework assignment; and if it's a homework assignment, you must do it yourself.
You learn more by getting it wrong and struggling and trying many ideas.
|
|
|
|
|
Picking up a good book on C might be good for a start.
|
|
|
|
|
A recursive function is simply one that calls itself. In the wrong hands, a recursive function can blow your application up. Try the following function to see what I mean:
public void MultiplyRecursively(int value, int multiplier)
{
int output = value * multiplier;
Console.WriteLine("Multiplied by ={0}", output);
MultiplyRecursively(output, multiplier);
} As this function has no terminating condition, all sorts of nasties can occur. I suggest that you run the code to see what happens.
|
|
|
|
|
|
public static Int64 Fibonacci(Int64 value)
{
Int64 oldnum = 1;
Int64 currnum = 1;
for (var i = 0; i < value; i++)
{
var next = currnum + oldnum;
oldnum = currnum;
currnum = next;
}
return currnum;
}
|
|
|
|
|
Hi, I have encounted a NullReferenceException problem while using SendKeys.
'TestWinAPI.vshost.exe' (Managed): Loaded 'C:\TestWinAPI\bin\Debug\TestWinAPI.exe', Symbols loaded.
'TestWinAPI.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'
A first chance exception of type 'System.NullReferenceException' occurred in System.Windows.Forms.dll
When I enable the exception capture, it shows the exception is being raised in SendKeys
private void btnAllinOne_Click(object sender, EventArgs e)
{
int hwnd = 0;
IntPtr hwndChild = IntPtr.Zero;
if (tbxProc.Text.Length == 0)
{
MessageBox.Show("empty process string"); return;
}
hwnd = FindWindow(null, tbxProc.Text);
if (hwnd == 0)
{
if (MessageBox.Show("Couldn't find the " + tbxProc.Text + " application. Do you want to start it?", "TestWinAPI", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
}
}
else
{
SetForegroundWindow(hwnd);
SendKeys.Send(tbxEditText.Text + "{ENTER}");
}
}
Anyone knows why is that?
|
|
|
|
|
tikcireviva wrote: Anyone knows why is that?
Either tbxEditText is null or it's .Text property is null. Assign the contents of the textbox to a string. On the next line, create a statement to concatenate the constant "{ENTER}".
Those three separate things "can" be done in a single line of code, but don't "have to". Dividing them up makes debugging a lot easier.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I think this is an exception which will be caught and handled internally within the SendKeys class. Debugging with "break when an exception is thrown" enabled is letting you see this exception which you don't really need to know about.
If you set the Visual Studio debugging option "Just my code" it should stop this nonsense!
Alan.
|
|
|
|
|
Hi !
Pardon for my bad english.
Ive been working this code for weeks,
foreach (Control Ctrl in this.Controls)
{
switch (Ctrl.GetType().ToString())
{
case "clarinrt.form.other.sdate":
if (Ctrl.Tag.ToString() != "") Ctrl.DataBindings.Add(new Binding("Text", formdataset, Ctrl.Tag.ToString()));
break;
case "clarinrt.form.other.slookup":
if (Ctrl.Tag.ToString() != "") Ctrl.DataBindings.Add(new Binding("Text", formdataset, Ctrl.Tag.ToString()));
break;
case "clarinrt.form.other.scheck":
if (Ctrl.Tag.ToString() != "") Ctrl.DataBindings.Add(new Binding("Checked", formdataset, Ctrl.Tag.ToString()));
break;
case "clarinrt.form.other.snumeric":
if (Ctrl.Tag.ToString() != "") Ctrl.DataBindings.Add(new Binding("Text", formdataset, Ctrl.Tag.ToString()));
break;
case "clarinrt.form.other.stext":
if (Ctrl.Tag.ToString() != "") Ctrl.DataBindings.Add(new Binding("Text", formdataset, Ctrl.Tag.ToString()));
break;
case "clarinrt.form.other.sdropdown":
if (Ctrl.Tag.ToString() != "") Ctrl.DataBindings.Add(new Binding("SelectedIndex", formdataset, Ctrl.Tag.ToString()));
break;
default:
break;
}
}
For each control, TAG property will be filled such as "account.detail" refering to a column in table name, while formdataset is Dataset for this form.
This code in Load method on base form. the problem with sdropdown and scheck which inherited from combobox and Checkbox. If I comment out, those two part, Databind work fine.
Can someone told me, what I should do ? sdropdown will be databind with Integer column while scheck will be databind with Boolean column
Thank you for your help...
|
|
|
|
|
You're abusing the "Tag" property. Databinding works best for properties, not for function-calls like "ToString".
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi There !
I've using some properties set in my class to replace Tag
public string cfield { get; set; }
but it is doesnt work for checkbox and combobox.
Thank you for your help.
|
|
|
|
|
A dataset doesn't implement INotifyPropertyChanged ; you might need to create a wrapper for it.
public partial class Form1 : Form, INotifyPropertyChanged
{
bool _test;
public bool Test
{
get { return _test; }
set
{
_test = value;
PropertyChangedEventHandler handler = this.PropertyChanged;
if (null != handler)
handler(this, new PropertyChangedEventArgs("Test"));
}
}
public Form1()
{
Test = true;
InitializeComponent();
checkBox1.DataBindings.Add(new Binding("Checked", this, "Test"));
}
private void button1_Click(object sender, EventArgs e)
{
Test = !Test;
}
public event PropertyChangedEventHandler PropertyChanged;
}
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi!
I need to remove Application launch and "Pin this application to taskbar" from the taskbar context menu for an application. Reason is that the application cannot start standalone, it must be feed with information from another application.
Does anyone know how?
Andreas Johansson
Senior software developer at Tieto Sweden
|
|
|
|
|
I'd recommend simply adding a messagebox if started without parameters; that way one is also warned when launching from another (unexpected) location.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Yes, i will do that as well.
But it would be nice to have both solutions
Andreas Johansson
Senior software developer at Tieto Sweden
|
|
|
|
|
Make sure the executable or shortcut name includes one of the restricted words:
- Documentation
- Help
- Install
- More Info
- Read me
- Read First
- Readme
- Remove
- Setup
- Support
- What's New
If it contains one of those words, you won't be able to pin it to the taskbar or start menu.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
This page: http://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx
tells how to do it properly
Andreas Johansson
Senior software developer at Tieto Sweden
modified 22-Apr-13 13:25pm.
|
|
|
|
|
I am a teacher in C# for students at beginner level.
One of my student keep having trouble that C#-express is very slow and now when we right-click the form to show code-behind nothing is shown.
It's very possible that the student is doing something wrong.
Is the best option to reinstall C# express 2010?
|
|
|
|
|
Could be. Is everything else working fine? Or is it just a very slow PC?
Has he tried creating a new project from scratch and seeing what that is like? If it works fine, then it's something stupid he has done, so add bits from the "slow" project until it slows down and you should have an idea what causes it.
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
Delete the file, add a new.
Could it have been that he simply deleted the code-behind-file?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Ok, thanks for the suggestions.
If he has deleted the codebehind but still have the other files, can you past it in from another projekt?
|
|
|
|
|
You're teaching this and you don't know the tooling? What's the backup policy? Is the source stored in a version control system?
|
|
|
|
|
Well, it´s not exactly University-level.
I do have a knowledge-gap there I admit but that wasn't my question.
The problem isn't so much that we doesn't have a backup. The problem is why it happens.
So do you have a solution to the problem or were just showing of?
|
|
|
|
|
larsp777 wrote: So do you have a solution to the problem or were just showing of?
I certainly do, and that's why I've asked if you know what your backup policy is. Failing that, select Project > Show All Files and see if the .cs file is still there. If it is, right click on it and select Include In Project. But seriously though - if you're teaching something, you should know how the tooling works. What do you say if a pupil asks you something a little bit off topic?
|
|
|
|
|
Thank you, I'll try that.
Well, you're right of coure and I like to think that I know the parts that we use mostly. However I do like to learn more.
If a student asks something of topic I says that I don't know but will find out.
Any tip is highly appreciated!
|
|
|
|