|
1 - Not a whole
2 - When your factor fails, you have to refactor.
3 - When you have to take off a legate, you use Delegates.

|
|
|
|
|
I'm not sure why you're asking this, if not for homework ?
Refactoring means the same in any language. Partial means you're using VS2005, it's a new keyword. A delegate is a fancy function pointer.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
LOL - it's not for homework. (After 12 years of college/grad school primarily in the 90s, those days are long gone.) I am learning C# here at work and want to use it for my first software project. I'm self-taught.
Thanks for your answers,
BP
|
|
|
|
|
BlitzPackage wrote: I am learning C# here at work and want to use it for my first software project.
OK - google would have answered them all, but...
a partial class has more than one .cs file, you just put 'partial' in your class definition, and the compiler will find all files relating to a class and merge them
Refactoring means to take existing code and change it's structure, most commonly by breaking a large function into several smaller ones.
A delegate is a function pointer, like I said. That means, a variable represents a function which can be assigned and called in code. All the event handlers in your forms code, like when you click a button, is handled with delegates.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
|
|
Thanks Ed,
I appreciate your answers.
Sincerely,
BP
|
|
|
|
|
hi
1. Partial - its a new kyeword introduced in c#2.0 and is use to write a class in distributed form
E.G - look at the designer of your form it is Form1.designer and where u write code is partial class form1. similarly u can have no. of class u want with the same name like partial Form1 and write and these will be combined in a single class i.e Form1.. Realy a good feature..like Sometime when no.of developers need to work on same class and so others.
2. Refactoring - provided to help u need writting templetes in code. For C# there is inbuilt Refactoring in dot net and for VB.net need to install third party. one can provide own code snipette and use refactoring to use them Simple best way to make lazy programmer.
3. Delegate - this is a something that works between event source and event target. It handles the event.
Atul kumar
|
|
|
|
|
I have to open Excel workbooks with different excel versions. With the reference for Excel2000 (Version 9.0) the code is
Excel.Application oEA = new Excel.Application();
oEA.Workbooks.Open ( "testfile.xls", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing , Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing );
This version needs 13 arguments for the Open-Method.
With a reference for Excel 2003 (Version 11.0) the same method needs 15 arguments.
My software has to run with both Excel-versions. If I compile with reference to Excel2003, my software does not run with Excel 2000 and vice versa.
Does anyone have an idea?
Ali Nehring
|
|
|
|
|
Create a class that wraps the object creation based on object type (2000, 2003, etc.). Then call you wrapper's Open, which just calls the correct version.
|
|
|
|
|
I tried this. I wrote 2 wrappers for both of the versions. Both of the wrapper have been implemented in different projects. If I reference to the wrappers, my project will not build, because there is a conflict:
Error: the dependency 'Interop.Excel, Version=1.5.0.0, Culture=neutral' in project 'NEAcoustics' cannot be copied to the run directory because it would conflict with dependency 'Interop.Excel, Version=1.3.0.0, Culture=neutral'
What can I do?
|
|
|
|
|
I am trying to write a DLL that has an event and am subscribing to the event from 2 different programs, but each of my programs is creating a new instance of the DLL.
The class is a singleton class and looks like this:
public sealed class clsEvents
{
public static readonly clsEvents Instance = new clsEvents();
private string _Value = "";
public event EventHandler ValueChanged;
public void OnValueChanged(EventArgs e)
{
EventHandler handler = ValueChanged;
if (null != handler)
{
handler(this, e);
}
}
public string Value
{
get { return _Value; }
set
{
_Value = value;
OnValueChanged(EventArgs.Empty);
}
}
} The singleton class only does half the work so that the same instance of the class is shared within each program but I need to use the same instance in both programs. I have set both programs to compile into the same directory so I know they are loading the same DLL but they are each creating their own instance of the class.
Finally, my question:
In VB6 it is possible to set the Instancing of a DLL to Multiuse and any programs that use that DLL would share the same global variables from the DLL. Is it possible to do the same thing in C# so that each of my programs uses the same instance of the singleton class?
Forgive me if I am going about this all wrong but hopefully someone can help. Please tell me if there is a better way to share events across multiple programs.
|
|
|
|
|
I'm afraid I think you're out of luck with this. Each of your programs runs in its own process and the operating system ensures that processes are independant of one another. Your dll will be loaded twice - once into each process, and even though you have implemented a singleton you ultimately have two of them on your computer.
You need to look at inter-process communication, something like named pipes perhaps or you might be able to get away with Mutexs. Hopefully someone here might have done this before.
Regards,
Rob Philpott.
|
|
|
|
|
I'm not certain of my solution...I'm just trying to throw ideas your way. What about exposing this as a web service and having it influence a state machine on your server? Then, you could just proxy into the service in both apps and whenever you would trigger the event from inside each of the programs, it would actually fire the event in a single location. But again, I might be oversimplifying your specific problem.
|
|
|
|
|
...a web service is my preferred choice for allowing concurrent execution of a shared process. They're fairly straight forward and since replies from the server are sent as SOAP, they can be consumed by pretty much any language you want to work in.
|
|
|
|
|
How to reveal values of all public properties of an object, without referring to property names?
Thanks.
|
|
|
|
|
Looks like Civic has the same homework!
|
|
|
|
|
It does indeed.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Thank you. The problem is solved.
|
|
|
|
|
I have an object and want to call a method which will automatically go through all its properties and display its values. How can i do that without manually specifying object.length for example.
|
|
|
|
|
|
|
Civic06 wrote: I have an object and want to call a method which will automatically go through all its properties and display its values.
Use reflection. Call GetType() to get the object's type (I presume that is also an unknown). From there you can GetProperties() . For each of the PropertyInfo objects you can now invoke the getter method. This will return the value of the property. It is then up to your application how to render that to the user.
|
|
|
|
|
I'm having an error message sounding like :
Prepared statement '(@id text)SELECT * from isp_email.staff where @id like +txtname.' expects parameter @id, which was not supplied.
This message appear when I press button to select a row at run time. What could be the problem?
SqlCommand myCommand = new SqlCommand();
myCommand.Connection=con;
myCommand.CommandText="SELECT * from isp_email.staff where @id like +txtname.Text";
SqlParameter myparam = new SqlParameter("@id",SqlDbType.Text);
myparam.Value=ID;
myCommand.Parameters.Add(myparam);
SqlDataAdapter myAdapter=new SqlDataAdapter(myCommand);
DataSet ds = new DataSet();
myAdapter.Fill(ds);
con.Open();
myCommand.ExecuteNonQuery();
dgupdate.DataSource=ds;
dgupdate.DataBind();
con.Close();
Thank you.
|
|
|
|
|
That error does not match what I see. However there is an error here:
nclauder wrote: myCommand.CommandText="SELECT * from isp_email.staff where @id like +txtname.Text";
The parameter @id is used in place of column name.
Also, txtname.Text will not be understood by SQL Server as it has no knowledge of your form. If you want to use the value from your textbox control then you really need to validate the value and/or sanitise its value and put send it as a parameter. Attempting to inject it will just open your application up to security holes.
|
|
|
|