|
Hi All,
I have given an interview. They asked me one question on OOP concept.
I could'nt able to answer, can anybody help me to find the solution?
Question
class a
{
private double myclass()
{
//coding stmt;
}
}
This class is kept in dll.
In main class you want to call method myclass how you will call b'coz that class is private method.
|
|
|
|
|
It's not possible to call the method directly as it is private. You may use reflection to do this, I guess.
|
|
|
|
|
The answer is that you don't, private members are accessible from inside that class only. You can work around this using reflection but unless you have no other choice you really really shouldn't do this.
|
|
|
|
|
You can do this using Reflection, but in an interview it's always worth pointing out that you SHOULDN'T do this because this is breaking the basic reasoning behind making a method private.
|
|
|
|
|
There's an easier answer than reflection: Add another function in class a that's public and calls myclass():
public double getMyClass ()
{
return myclass ();
}
Yes, it's a silly answer, but that was a silly question.
|
|
|
|
|
I want Visual Studio to auto-change the active project when I change sourcefiles. I don’t want to right-click a project an choose ”Set as startup project”. (VS 2005)
_____________________________
...and justice for all
APe
|
|
|
|
|
d00_ape wrote: I don’t want to right-click a project an choose ”Set as startup project”. (VS 2005)
so how does it know what you want to do? Guess?
Bob
Ashfield Consultants Ltd
|
|
|
|
|
On the cpu I'm use now VS2005 automaticaly sets "active project" on the project that my current code-file exists. Current codefile = Selected i Project Explorer or active in code-view.
_____________________________
...and justice for all
|
|
|
|
|
Most of my projects are DLLs, many are Windows Services, setting those projects as Startup would not be wise.
|
|
|
|
|
Hi expets, I created a datagrid column as a templete column.It is a textbox field.So how i validate that templete column(textbox)?
CheeN
|
|
|
|
|
This[^] was my first hit when I googled. BTW, this question has to be in ASP.NET forum.
|
|
|
|
|
I want my app to have a few global functions that are performed whenever certain keys are pressed. That's easy to do as long as a certain control has focus, but as soon as one of the other numerous controls on my form receives focus, the key press events are no longer fired for the control that cares, with the events instead firing for whatever random control happens to have focus.
The pull-down menu controls seem to have solved this problem because they process Alt presses regardless of what control has focus. Does anyone know how I can do this too?
Thank you!
|
|
|
|
|
Set the form's KeyPreview property to true and you can handle all the key presses in the form's various key events rather than using the individual control's.
Dave
|
|
|
|
|
Hi All,
How can i know from the keyboard scan code what is the real key ?
I using KBDLLHOOKSTRUCT Structure in my keyboard hook to get the pressed keyboard information - But i still don't understand how can i know what the meaning of the key that was pressed even if i know the scanCode of the pressed key.
I don't want to use "switch..case" to check for each option pair So ... i looking some .net Framework class ( or win32 function ) that can find the value of the scanCode of the pressed key.
Beside this - how can i know if the key that pressed is 'A' or 'a' or '5' pr '%' - ?
Thanks for the help
|
|
|
|
|
Hi
i have the situation to fetch similar values using fuzzy lookup. here i dont know how to pass variables which contains input values[comes from my application] to the fuzzy look up without using datasource.
Can anyone tell how?
thanks in advance
sari
|
|
|
|
|
I have no idea what you're asking. What fuzzy lookup ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
hi
How to delete record using check boxes in datagrid.
that is if check box is checked the record should be deleted and again when checkbox is checked the record must undelete.when the record is deleted the "edit" command of datagrid must deactivate.
iam using stored procedures to delete records that is updating flags.
can any one help me in coding.
thanks
|
|
|
|
|
I guess you need to have a deleted flag ( if you delete records from the DB, you cannot undelete ). Then it's easy, all flags are set by the checkbox value, on or off.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi all,
I have 3 form in my application: fMain,fA,fB, Where create object fA() and fB() in fMain to use delegate.
fMain <---delegate---> fA
<---delegate---> fB
Now, i would like to force to refresh fB when fA was edited. How can i do it?
Any tips are welcome.
regards
cocoonwls
|
|
|
|
|
OK, I have an app which uses windows media player as a control. I need to build a 64 bit version. However, when I set the target to 64 bit, it says the build succeeded, but no code files are in the target directory. I think that may be because a setting is wrong, but when I fix it, I get this:
Error 49 An attempt was made to load an assembly with an incorrect format: E:\Source code\OVS\DiagnosticImagingAssistant\obj\x64\AussieRelease\DiagnosticImagingAssistant.exe. E:\Source code\OVS\DiagnosticImagingAssistant\SGEN DiagnosticImagingAssistant
Also a bunch of warnings like this:
Warning 33 Assembly generation -- Referenced assembly 'System.Data.dll' targets a different processor DiaFileWatcher
Warning 34 Assembly generation -- Referenced assembly 'mscorlib.dll' targets a different processor DiaFileWatcher
Do I need to be on a 64 bit version of windows to build 64 bit ? If it just errors out, what's the point of having the setting ?
It's actually complaining that a dll I wrote, which is being built as 64 bit, and imports windows media player, is the wrong format:
C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\sgen.exe /assembly:"E:\Source code\OVS\DiagnosticImagingAssistant\obj\x64\AussieRelease\DiagnosticImagingAssistant.exe" /proxytypes /reference:..\Odyssey.Windows.Controls\bin\x64\AussieRelease\AxInterop.WMPLib.dll /reference:..\OVSCommon\bin\x64\AussieRelease\Interop.DexterLib.dll /reference:..\Odyssey.Windows.Controls\bin\x64\AussieRelease\Interop.WMPLib.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll /reference:..\Odyssey.Windows.Controls\bin\x64\AussieRelease\Odyssey.Windows.Controls.dll /reference:..\Odyssey.Windows.Controls\bin\x64\AussieRelease\Odyssey.Windows.Forms.Controls.dll /reference:..\OVSCommon\bin\x64\AussieRelease\OVSCommon.dll /reference:..\OVSImaging\bin\x64\AussieRelease\OVSImaging.dll /reference:..\OVSCommon\bin\x64\AussieRelease\PresentationCore.dll /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\ReachFramework.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll" /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.EnterpriseServices.dll /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.IdentityModel.dll" /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Management.dll /reference:..\OVSCommon\bin\x64\AussieRelease\System.Printing.dll /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.Runtime.Serialization.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.ServiceModel.dll" /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Web.Services.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\UIAutomationProvider.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\UIAutomationTypes.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\WindowsBase.dll"
SGEN : error : An attempt was made to load an assembly with an incorrect format: E:\Source code\OVS\Odyssey.Windows.Controls\bin\x64\AussieRelease\Odyssey.Windows.Controls.dll.
Done building project "DiagnosticImagingAssistant.csproj" -- FAILED.
any suggestions appreciated.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
modified on Monday, June 2, 2008 12:14 AM
|
|
|
|
|
Hi Christian,
I've never done any 64 bit stuff - but found these on the MSDN forums if they're any help.
Clickety[^]
Clickety[^]
Dave
|
|
|
|
|
Just found this[^] one too which may be of more help in step 3.
Dave
|
|
|
|
|
Hello everyone,
I am new to Reflection. Two basic questions about Reflection after some tests.
1.
About BindingFlags.Instance, I think it should refer to all entities which are not static but instance level, but I have made some tests and found it is not correct.
What does BindingFlags.Instance mean?
2.
What is the differences between FieldInfo and FieldType classes? In what situation should we use FieldInfo and in what situation should we use FieldType?
thanks in advance,
George
|
|
|
|
|
George_George wrote: I have made some tests and found it is not correct
Post your code.
|
|
|
|
|
Thanks PIEBALDconsult,
Here is my code to test the Instance status,
class Program
{
class Foo
{
static int abc;
int bcd;
}
static void Main(string[] args)
{
Foo f = new Foo();
FieldInfo[] fields = f.GetType().GetFields(BindingFlags.Instance);
return;
}
}
regards,
George
|
|
|
|