|
Wrapper class is an avtivity of migrating non OO types in languages in OO types i.e. in case of C# from basic value types (excepting structs, enums) to class types.
If this is somewhat difficult to consume consider following example.
Say you have one 'int' value which you want to wrap. So you would write a class like:
public class Integer<br />
{<br />
private int var;<br />
<br />
public Integer(int v)<br />
{<br />
this.var = v;<br />
}<br />
<br />
public get(){...}<br />
public set(){...}<br />
}
So now you have wrapped a simple integer into a class Integer which will be an OO type. Fortunately they are directly available in C# libraries.
Now a millon dollar question. What is use of this??
See, when you are going to deal with something which requires complete OO types e.g. object serialization, remoting you need this concept. As the complete manifest information is required in order to perform the activity.
That is it.
Chaitanya Joshi
|
|
|
|
|
No, a wrapper class is typically a class that exists solely to import and expose functionality that is otherwise not available. For example, my article on using the Canon SDK in C# is a wrapper class, the class exposes methods which call the methods in the Canon SDK dlls, via p/invoke. My classes are a wrapper, I do not offer Canon camera connection, simply a way to call a C++ SDK from C#.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I try to explain you my view,
A wrapper class enables reusability because you add an "interface" beetween implementation code and the use of it. If it's well designed, you can change implementation and its impact on use is minimal. If not, you will have to do a lot of changes in use code.
Visit my blog at http://dotnetforeveryone.blogspot.com/
|
|
|
|
|
y should somebody declare the function or variable as static.what's the advantage
Soniagupta1@yahoo.co.in
Yahoo Messenger Id = soniagupta1
|
|
|
|
|
|
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;
|
|
|
|