usually I will use global application class that act as session in my application, the global class contains application global variables stored as list (usually i use sorted list). thus this variable can be accessed by other object in application
sample of global class like this
public static class GlobalApplication
private static SortedList<string,> globalVars = new SortedList<string,>();
public static void AddGlobalVar(string variableName, object variableValue)
public static object GetGlobalVar(string variableName)
by use that class u have to add your database connection or other object to store to global variable and access it within your application. i.e
I have a base class that implements the methods "DoSomething()" and make it virtual
a) Is there anyway I can force the derivated class to override it too
b) I can't make it abstract, because I need something to be done in the base and in the derivated class
c) I also would like to force the programmer to call base.DoSomething() inside it's own method to be sure the base method to be executed too.
If I have a log method, that I'd like to be called from inside every method, is there anyway to get all parameters and values from the function where it's been called without having to specify one by one?
This is what I would try:
create a non-virtual public or protected method "PseudoVirtual()" that calls two other
methods say "fixd()" and "virtuaal()";
stuff whatever needs to be done anyway in private fixd();
and provide a protected virtual "virtuaal()" which, when overriden, effectively provides
overrides for "PseudoVirtual" while enforcing a call to "fixd()".
I don't think that is possible (unless you write some code that modifies your IL code).
If it can be done, I'm interested!
I have to pass pixelformat as a parameter when performing lockbits. But for grayscale images, there is only "Format16bppGrayscale." Does this format work with 8 bit grayscale images? If not, how do i use lockbits with 8bit grayscale images?
I have a form with a listbox controls that has some items in it.
When i double click a item from the listbox it opens a new form that as the title of the item.
(you will see that on some chat applications)
OK, code for the above is fine.
Now, i don´t want to open new forms with the same title, i want to prevent that.
If a form titled "bob" already exists and i double click "bob" item from the listbox, i want the existing form to be focused not open another form with same title!!!
Can anyone help me here?
how can i count forms, get their titles so that a can achive that
i suspect that i have to create some kind of mdiparent/child forms to do that.
you could keep a Dictionary<string,form> that maps titles to Forms, and before opening
a new Form, look for an existing one if any, then act accordingly. You would have to
remove entries when forms get closed then, using the Closed event.
Or use Application.OpenForms and search for a matching title.
I r multithreading! however it's not looking so good... I'm using a beginInvoke to fire off pings at other machines on my network I'm pulling the names from ldap sychronously. Anyways the question i had was "Are async delegates manged by the threadpool"... I thought i read somewhere that they were indeed managed via the threadpool... So next question is how come when i do something like this "ThreadPool.SetMaxThreads(10,10);" The app still fires off the max threads that the threadpool can manage? I.e. 20-25... Hope someone can shed some light on this.. Lemme know if you would like to see some code if that would help define my question/problem! Thanks in advance for any reply's even if it's stfu noobzor and go read a book!
I know the human being and fish can coexist peacefully. -George Dubya Bush
You can't cast an object to something that it isn't. You can only cast an object to it's actual class, any of it's base classes, or any of the interfaces that it implements.
C# is type safe, so the object contains information about it's actual type. When you do a cast, you cast the reference, but the object still remains the same type. Therefore, when you cast the DataTable reference to object, you get an object reference pointing to a DataTable object. You can't then cast this to msdatasrc.DataSource, as the actual type of the object does not inherit that class.
If the control can't use a DataTable as data source, you have to copy the data from the DataTable into something that the control can use.
Despite everything, the person most likely to be fooling you next is yourself.
Last Visit: 18-Feb-20 6:28 Last Update: 18-Feb-20 6:28