|
Thanks for your answer
I am sorry but I dont think I have made it clear that I want the input to be like a pointer in C++, which I know can not be done (at least not in managed/safe mode). If I were to write the code in C++ I think the constructor would be like this.
public Module(Object* source)
{
this.input = source;
this.output = new Object();
}
and later the constructors will be called like this
mod1 = new Module(&firstInput);
mod2 = new Module(&mod1.output);
- Lothver
|
|
|
|
|
Lothver wrote: I dont think I have made it clear that I want the input to be like a pointer in C++,
Yes, I didn't get that from the first description. Using real pointers cannot be done in C# without marking the code block as "unsafe".
Other than the method described using events to realize when the property value has changed, I don't think it is possible to do what you want without pointers.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
I am trying to convert an array of grayscale values into an Image for viewing in a picturebox. What I am currently doing is converting the data to rgb and then converting it to a bmp. I would like to cut out the extra steps. Does anyone know of any methods to do this?
|
|
|
|
|
Hi,
Most applications i know, when the MDI childs are maximized, the three little icons which permit the minimize, maxmimize and window close disappear from the form itself and goes to the end of the menu bar of the mdi parent.
How can i implement such behaviour?
Thx,
Nuno
|
|
|
|
|
If you are using MDI childs in .NET2.0 it's done...
But, if you don't see it and you wanna implement it you can simulate a menu with a toolstrip top docked and showing or hiding three buttons that are right aligned...
|
|
|
|
|
I am new to C# programming and I would like to ask for opinions on some coding procedures.
I have a user input sentence that goes into “strValue”, (See below) from there it gets cut into separate words.
I then need to add the first letter and “ay” to the end of the word. (So that it forms a pig Latin style word.)Then I need to restring them back into the same order that they were originally. I think I'm putting them into an array, and if so there is going to be no problem getting them back.
What I would like to know is “Would I be better off to place the string manipulations into separate constructors, methods, or maybe lumping them all together in either one”.
I know that each person does it differently, but I would like some feedback on what may be a better way to do this. Thank you.
private string strValue = " ";<br />
private string s = " ";<br />
<br />
char[] separator = { ' ' };<br />
string[] s;<br />
s = strValue.Split(separator);<br />
foreach (string word in s)<br />
{<br />
Console.Write("{0}" + " ", word);<br />
}<br />
<br />
<br />
s = strValue.Insert(); <br />
<br />
s = strValue.Insert(); <br />
<br />
s = strValue.Remove(0, 1); <br />
|
|
|
|
|
JMOdom wrote: What I would like to know is “Would I be better off to place the string manipulations into separate constructors, methods, or maybe lumping them all together in either one”.
Placing the string manipulation within a function would make allot of since. Using a StringBuilder object would help with any processing overhead, only if your planning on calling your new function thousands of time but is still a good practice when manipulating strings.
All and all it should be an efficient pig Latin creator.
I'm listening but I only speak GEEK.
|
|
|
|
|
I've been reading a lot about this, and I asked a question earlier but I think I phrased it incorrectly.
Lets say I have an Excel sheet open....it has been previously saved and located at C:\test.xls
So this excel Sheet is already OPENED on and on my taskbar, I can edit/change whatever I want.
Is there a way to have C# access that ALREADY opened Excel sheet?
It does not matter if I can save that excel sheet. I only want ONE instance of it open. The same instance on my taskbar/desktop. All I want is to make some calculations in C# and then put them in ANY cell in the Excel sheet. This is for viewing only. Can anyone help me with this?????
|
|
|
|
|
Have you looked at the Office Object Model for Excel. Your answer is there. Make sure you use the Primary Interop Assemblies published by Microsoft.
led mike
|
|
|
|
|
I use File Watcher to monitor a folder for any new files. The intention is that when an XML file gets dropped in that folder, filewatcher will send an event and the event handler will take care of it. But how do i get the event handler to now to read all the files in that directory. So if 10 XML files get dumped in there. i am assuming that in the event handler i have to use something like FindFirstFile in C++ to actually load the files regradless of name. DOes C# have an equivalent or is there a better way to do this?
|
|
|
|
|
If 10 files get dropped there, you should have 10 calls to your handler. I can't remember exactly (it's been a while), but I'm pretty sure the calls come back via the thread pool so even if you wanted to process them all from one of the handler calls, you'd have to make sure that only one of the calls is actually processing the files, and not the others, with a lock or mutex of some sort.
If this is for sure how you want to handle it (process from a single handler call), you could do something like this (after first making sure the code is only running on one of the handlers).
<code>
void watcher_Changed(object sender, FileSystemEventArgs e)
{
string[] fileList = Directory.GetFiles(Path.GetDirectoryName(e.FullPath), "*.xml");
foreach (string file in fileList)
}
</code>
-----
In the land of the blind, the one eyed man is king.
|
|
|
|
|
When I create a user control (WinForms), and add that control to another form, I automatically see all (relevant) public properties in for Form Designer. Nice!
Question:
How can I attach a comment to a proeprty, so it is displayed in the Property Editor?
|
|
|
|
|
Hello,
Set the following Attributes to the property!
[System.ComponentModel.Category("YourCategory"), System.ComponentModel.Description("YourDiscription")]
All the best,
Martin
|
|
|
|
|
Hi guys,
I need some help please, i have tried googling for almost 5 hrs now with no luck on this issue. I have 2 listviews where I am moving data from one list to another. When I move the same data, I want it to give me an error saying list 2 already contains the configuration.
I tried, listview.items.contains and even listview.items.equals and no luck.
Please help!!!!!
sasa
|
|
|
|
|
nevermind. I figured it out.
sasa
|
|
|
|
|
There is an explanation about how to raise events in MSDN at the address below:
http://msdn2.microsoft.com/en-us/library/ms173168.aspx
It says:
To avoid a race condition where the last handler can be removed between the null check and the invocation of the event, event sources should also create a copy of the event before performing the null check and raising the event.
private void RaiseTestEvent()
{
// Safely invoke an event:
TestEventDelegate temp = TestEvent;
if (temp != null)
{
temp(this, new System.EventArgs());
}
}
But Isn't the delegate TestEventDelegate a reference type? If I'm right, then assiging the Event TestEvent to the temp variable should not make a seperate object with similar data and state. It should rather create another pointer to the same object as it's supposed to do in reference types realm. So even in the race condition mentioned above, creating the temp variable should not be a solution. Because in that situation, removing the last event will cause the temp variable become null just like TestEvent. However the code above works well and eliminates the race condition. This makes a confusion for me on how it's possible that the variables are reference types while the code works well.
Any idea?
|
|
|
|
|
Yes, when you copy the reference into the temp variable, you are only copying the reference itself, the object stays the same.
The reason that this prevents the reference from becoming null is that you have a copy of the reference. If the reference that is returned from the TestEvent property is changed to null, your copy of the reference is still unchanged and is still referencing the object.
---
single minded; short sighted; long gone;
|
|
|
|
|
Do you mean creating a copy of a reference type prevents it from becoming null when the copy is set to null and vice versa??? As far as I know, both of the variable must be referring to a same object. So any change in each one must be reflexed in the other one. I didn't get your meaning!
|
|
|
|
|
It's not the object that is changed to null, it's the reference.
The reference and the object are separate entities. Changing the object doesn't change the reference, and chancing the reference doesn't change the object. If you have a reference that points to an object and sets the reference to null, that doesn't change the object, it only makes it inaccessible through that specific reference.
Similarly, two references pointing to the same object are three separate entities. Changing the object doesn't change either reference, and changing one reference doesn't change the object or the other reference. Setting one of the references to null doesn't change the object and doesn't change the other reference.
---
single minded; short sighted; long gone;
|
|
|
|
|
I am trying to set the global value into into combobox and the value is not showing up in the combobox. Need help. Here is the code.
sql1 = @"SELECT locationNo, cast(locationNo as varchar) + cast(' - ' as varchar) + cast(locationName as varchar) as locationNames FROM Locations WHERE LocationNo = '" + VehicleGlobal.gv_Location + "'";
SqlDataAdapter da1 = new SqlDataAdapter(sql1, conString);
da1.Fill(ds, "Locations");
DataTable dt = ds.Tables["Locations"];
foreach (DataRow row in dt.Rows)
{
VehicleGlobal.gv_LocationName = row["LocationNames"].ToString();
}
this.cboLocation.Text = VehicleGlobal.gv_LocationName
|
|
|
|
|
try changing this
this.cboLocation.Text = VehicleGlobal.gv_LocationName
to
this.cboLocation.Datasource = VehicleGlobal.gv_LocationName
this may not work, it depends what type your VehicleGlobal.gv_LocationName property is.
|
|
|
|
|
hi,
I want to validate the onecolumn in datagridview like only digits entry.
By using keydown/keypress event how can i validate it for a perticular
column in Dtagridview.
Help me please
With Regards
prasad
|
|
|
|
|
|
try below line
if(Dtatgrid1.cells[row][col].value==?)
|
|
|
|
|
hi all,
I have set the password char for a textbox as *. and i am able to mask the password. I have a check box which prompts for showing the password.
Now how can i unmask the password char so that the password is visible in the textbox?
Thanks in advance.
Regards
Anuradha
|
|
|
|