|
|
If you have a static function or variable you do not need to create an object to have access to that function/variable
class X
{
public string nonStatic = "hh";
public static string staticVariable = "xx";
public void NonStaticFunction()
{
..
}
public static void StaticFunction()
{
...
}
}
To have access to nonStatic variable and NonStaticFunction you have to write something like this
X obj = new X();
obj.nonStatic;
obj.NonStaticFunction();
To access the static variable and function you have to write code like this
X.staticVariable;
X.StaticFunction;
Hope it helps.
There are 10 kinds of people: those who understand binary and those who don't
|
|
|
|
|
|
Hi All,
I wan't to compare two SQL Server databases. i.e., I wan't to check both databases structure and add if necessary.
In my project I am using SQL Express database and now we update some fields in the database. So, if we wan't to update the new versions for those customers who are using old database we need to update the database also. It is not recommanded that to manually add the fields in the database and is time taking too. So, I wan't to compare two databases(old and new) and update the fields in the old database.
Any confusion in my question plz let me know so that I can be more clear.
Thanks for any reply,
Narayana Ayyagari.
|
|
|
|
|
There are several commercial packages that does this very well, no free ones I know of. In SQL2005 you can try what is suggested here: http://blogs.geekdojo.net/richard/archive/2007/06/04/134600.aspx[^]
xacc.ide
The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach."
|
|
|
|
|
hi ,
this may sound very stupid but i want some body to explain to me what is the difference between
public static void Main()
{
}
AND
public void Main()
{
}
what is the purpose of using void in the main function ie anyway a main function doesnot have to return any values right
expecting a reply at the earliest
j
|
|
|
|
|
Trustapple wrote:
expecting a reply at the earliest
Read this [^] article.
Trustapple wrote: what is the purpose of using void in the main function ie anyway a main function doesnot have to return any values
You use void to let the compiler know that the function doesn't return any values.
There are 10 kinds of people: those who understand binary and those who don't
|
|
|
|
|
Hi..
Trustapple wrote: public static void Main()
public: It means that this method can be accessed from anywhere....
static: without creating the object of this class we can call the methos directly by using its class name...
void: As this main method is a function it should return something so we specifying void which means that it will not return any value...
main: it is a function name where the program starts executing...you can call this function from any other functions tooo like....
public void callMain()
{
main();
}
Regards,
Sandeep Kumar.V
|
|
|
|
|
I have searched Code project for the articles for programming using MAPI.
But I couldn't find a solution for it.
Can any one give the link or the suggestions to program using Extended MAPI in .NET.
Thanks a lot in advance.
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
Try this article [^]
Hope it helps.
There are 10 kinds of people: those who understand binary and those who don't
|
|
|
|
|
Hello
Any body know how can I define a const table like this in c#
-----------+------------+--------------+---------------
int_number | int_number | float_number | bool_variable
int_number | int_number | float_number | bool_variable
int_number | int_number | float_number | bool_variable
...
thanks
Beginner in C#
|
|
|
|
|
|
What do you mean by a "const table"?
Constants can only be simple values, like a number or a string. You can's create collecions of objects as constant.
---
single minded; short sighted; long gone;
|
|
|
|
|
I done the rs232 application.Executing is successfully.But showing Unable to open comport.In my application i have open the comport.
|
|
|
|
|
I want to write data received from serial COM port to an Excel data base. I'm really confused abt how to use it. If sumone can help me it'll be really appreciated.
Thank you
|
|
|
|
|
There are several ways to do this. One is presented here [^] which uses Microsoft Excel Object Library. You can also try writing to a CSV file, which is easier, and Excel knows how to open these kind of files or you can try using OleDB or ODBC. You can find the connection string here [^], and if you search on google you will find several tutorials and applications.
Hope it helps.
There are 10 kinds of people: those who understand binary and those who don't
|
|
|
|
|
Thanx alot for the help, it was really useful.
|
|
|
|
|
Error: The name port does not exit in current context.
This is my coding part
using System.IO.Ports;
namespace RS232_Tester
{
public partial class Rs232 : Form
{
string InputData = String.Empty;
// This delegate enables asynchronous calls for setting
// the text property on a TextBox control:
delegate void SetTextCallback(string text);
public Rs232()
{
InitializeComponent();
// Nice methods to browse all available ports:
string[] ports = SerialPort.GetPortNames();
// Add all port names to the combo box:
foreach (string port in ports)
{
cmbComSelect.Items.Add(port);
}
}
private void cmbComselect_SelectedIndexChanged(object sender, EventArgs e)
{
if(Port.IsOpen)port.Close();
port.PortName = cmbComSelect.SelectedItem.ToString();
stsStatus.Text = port.PortName + ": 9600,8N1";
// try to open the selected port:
try
{
port.Open();
}
// give a message, if the port is not available:
catch
{
MessageBox.Show("Serial port " + port.PortName +
" cannot be opened!", "RS232 tester",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
cmbComSelect.SelectedText = "";
stsStatus.Text = "Select serial port!";
}
}
private void button2_Click(object sender, EventArgs e)
{
if (port.IsOpen) port.WriteLine(txtOut.Text);
else MessageBox.Show("Serial port is closed!",
"RS232 tester",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
txtOut.Clear();
}
private void button1_Click(object sender, EventArgs e)
{
txtIn.Clear();
}
private void port_DataReceived_1(object sender,SerialDataReceivedEventArgs e)
{
InputData = port.ReadExisting();
if (InputData != String.Empty)
{
string[] ports = SerialPort.GetPortNames();
// txtIn.Text = InputData;
// because of different threads this
// does not work properly !!
foreach (string port in ports)
{
cmbComSelect.Items.Add(port);
}
}
}
/*
To make a thread-safe call a Windows Forms control:
1. Query the control's InvokeRequired property.
2. If InvokeRequired returns true, call Invoke with
a delegate that makes the actual call to the control.
3. If InvokeRequired returns false, call the control directly.
In the following code example, this logic is
implemented in a utility method called SetText.
A delegate type named SetTextDelegate encapsulates the SetText method.
When the TextBox control's InvokeRequired
returns true, the SetText method creates an instance
of SetTextDelegate and calls the form's Invoke method.
This causes the SetText method to be called
on the thread that created the TextBox control,
and in this thread context the Text property is set directly
also see: http://msdn2.microsoft.com/en-us/library/ms171728(VS.80).aspx
*/
// This method demonstrates a pattern for making thread-safe
// calls on a Windows Forms control.
//
// If the calling thread is different from the thread that
// created the TextBox control, this method creates a
// SetTextCallback and calls itself asynchronously using the
// Invoke method.
//
// If the calling thread is the same as the thread that created
// the TextBox control, the Text property is set directly.
private void SetText(string text)
{
// InvokeRequired required compares the thread ID of the
// calling thread to the thread ID of the creating thread.
// If these threads are different, it returns true.
if (this.txtIn.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(SetText);
this.Invoke(d, new object[] { text });
}
else this.txtIn.Text += text;
SetText(InputData);
}
}
Srinu
|
|
|
|
|
You are trying to use a variable that is not declared where you are trying to use it. There are only two variables declared with the name port, and they only exist inside the foreach loops.
---
single minded; short sighted; long gone;
|
|
|
|
|
I want the modifying code.Where it is modify in my application.
|
|
|
|
|
You are using variables that you never created. You have to create every variable that you use, and you have to assign it a useful value.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi Guys. I have tried a few dirrent ways of doing this but none of them seem to work for me. I am trying to get the "username" copied from my logon form into the Main form.
The logon form is called from the mainform. user enters username and password and it gets validated in the code as below. If all is fine then the main form is displayed.
However, I am trying to get the username from textBox1 copied to a label "lblUserName" in the Mainform. How do I get this to work? I am able to get the text from textBox1 copied to a lbluser on the Logon form but can't get it over to the Mainform. Any help would be GREATLY appreciated.
public partial class Logon : Form
{
public Logon()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
NEF frm = new NEF();
if (textBox1.Text == "maphanga" && textBox2.Text == "marsha"
|| textBox1.Text == "nkosi" && textBox2.Text == "mdu"
|| textBox1.Text == "carrim" && textBox2.Text == "allerece"
|| textBox1.Text == "raphela" && textBox2.Text == "rachel"
|| textBox1.Text == "mazibuko" && textBox2.Text == "zoliswa")
{
this.DialogResult = DialogResult.OK;
}
else MessageBox.Show("Invalid username and or password supplied");
lbluser.Text = textBox1.Text;
frm.Close();
MessageBox.Show(lbluser.Text);
}
}
"I'm just so confused I can't remember my own name"
|
|
|
|
|
|
Why don't you add a property to the logon form:
...<br />
<br />
public string Username<br />
{<br />
get {return textBox1.Text}<br />
}<br />
...
And in the MainForm you add:
LogonForm oForm = new LogonForm();<br />
if( oForm.ShowDialog() == DialogResult.OK )<br />
{<br />
lbluser.Text = oForm.Username<br />
}<br />
else<br />
{<br />
}
Visit my blog at http://dotnetforeveryone.blogspot.com/
|
|
|
|
|
Brilliant. First suggestion that actualy worked. Much appreciated. I tried so many different suggestions and none of them worked.
Now I can sleep again!!!!!
|
|
|
|