|
Thank you but I would like to expose the enumeration to the client of the class. Maybe it is more a problem of scope.
For instance, to expose a private member of the base class, I would create a public property but I don't know how to do it for an enumeration.
|
|
|
|
|
public class A
{
protected SomeEnum e;
}
public class B : A
{
public SomeEnum E
{
get { return base.e; }
set { base.e = value; }
}
} You can't access private fields - not even in derivative classes. That's why they're declared as private.
Exposing an enumeration is like exposing any other type, be that a reference type or value type (which an enum is, along with primatives and structs).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
Well, all is ok...
I am sorry but I missed that in fact my class was not inherited from the class which defined the enumeration but from an inner class of it . It was more a problem of scope than of code...
Thank you for your replies,
Best regards
|
|
|
|
|
Hello,
how can I get the URL from an open Internet Explorer? I tried it on this way:
InternetExplorerClass IE = new InternetExplorerClass();
txtGetURL.Text = IE.LocationURL;
But this returns allways an empty string
|
|
|
|
|
Your going to need to use SPY++ to get the handle of the IE's addressbar (which is a combobox). Then you will use the User32.dll SendMessage and WM_GETTEXT, which is documented here PINVOKE.net[^]
/\ |_ E X E GG
|
|
|
|
|
Hi Friends,
I need to cast a string to long. I'm reading information from an XML file. The file contains information such as record's ID, Age. These are declared as C# type long. I'm using System.XML.XMLDocument class for reading XML File. All the values returned by XMLDocument object are in string format. so i get ID ang Age as strings not Long. Now i need to cast them as long so i can utilized them safely in my program... I've searched MSDN and it says type casting across differnt domain is not allowed.
Is there any workaround to cope up with this situation ???
Thanks in advance,
Regards,
Hatim Ali.
|
|
|
|
|
Use an overload of Int64.Parse to convert your string.
|
|
|
|
|
|
Hi Guys,
How to validate a TIME?
- After selecting the data from the database SQL SERVER I need to validate the time. IF it's > 12:00 am then I will not accept that particular record no specific dates.
ex0. 2004/06/20 12:01:43 AM - this is not allowed
ex1. 2004/06/20 12:00:01 AM - this is not allowed
if I used this sql statement using the ex0 or ex1 value it gives me a "0" value
select datepart(hh,requestdate) from dtrequest where requestno='DRAFT104' group by requestdate
Anybody who can direct me to a page where I can read and give me idea or solution, or if you can help me.
Thanks
/Dabuskol
|
|
|
|
|
dabuskol wrote:
IF it's > 12:00 am then I will not accept that particular record no specific dates
Then what records are you accepting? 12AM == Midnight, 12PM == Noon
So, the result you are getting from the datepart is correct. Zero-hundred-hours == Midnight.
When dealing with dates and times I always use the 24-hour clock - it is much easier to work with.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
|
dabuskol wrote:
12 PM..
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
hello there,
i want to take lively images from a webcam which connects to my PC from USB.
if you help me i will be very very happy.
have nice work.....
turgaytr@hotmail.com
T.A
|
|
|
|
|
you'd better have the driver and SDK of the webcam.
then you can do it better.
|
|
|
|
|
|
:-Ohai there,
i have a form with controlbox in my application. If the user click on close button. then I want to show a message box(MessageBoxbuttons.YesNocancel). i wrote different operation to handle all this three choices. but the funny thing is no matter if i click yes or No or Cancel this will dispose the form.
i want to dispose the form if the user select Yes.
Other wise i need to keep the form active( If user choose cancel or no).
any idea
Please feel free to contact.
Sreejith S S Nair - Bangalore
|
|
|
|
|
sreejith ss nair wrote:
any idea
Yep, you need to override the OnClosing event and capture the DialogResult from your user. Based upon the users response, change the Cancel property of the CancelEventArgs and pass it to OnClosing of the base class. Here is a quick example:
protected override void OnClosing(CancelEventArgs e)
{
DialogResult r;
r = MessageBox.Show("Do you want to quit?", "Quiting",
MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if(r == DialogResult.No)
e.Cancel = true;
base.OnClosing (e);
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
nice shoot dear
Please feel free to contact.
Sreejith S S Nair - Bangalore
|
|
|
|
|
I want to draw many strings in graphics, but I don't know how to get the size of the string in pixel (not the Length) to control them..
( As the function CSIZE GetTextExtent(CString) in Visual C++ )
Can you help me?
Cuoc doi ai biet dau ngay mai...
|
|
|
|
|
Minh Tong Tong wrote:
Can you help me?
Sure, if you read the MeasureString[^] method of the Graphics class, it returns a SizeF structure which gives you both the Height and Width of the string measured in pixels.
- Nick Parker My Blog | My Articles
|
|
|
|
|
does anyone have any straightforward method of clearing the console screen with an explanation?
i know it can be done...
|
|
|
|
|
|
thank you. i read it and implemented it. however, everytime i try to compile, it gives me an error
"needs an object reference for the nonstatic method 'nsClearConsole.ClearConsole.Clear()'"
so i created an object:
nsClearConsole.ClearConsole cls = new nsClearConsole.ClearConsole();
then i used it:
cls.Clear();
but when i compile, it says something about cls not being a namespace or class (did you miss a using or assembly reference?) or something like that...
any help?
|
|
|
|
|
Are you trying to write this as a singleton class? The following works for me:
using System;
using System.Runtime.InteropServices;
namespace Example
{
class ConsoleClass
{
private const int STD_OUTPUT_HANDLE = -11;
private const byte EMPTY = 32;
private int hConsoleHandle;
public ConsoleClass()
{
hConsoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
}
[StructLayout(LayoutKind.Sequential)]
struct COORD
{
public short x;
public short y;
}
[StructLayout(LayoutKind.Sequential)]
struct SMALL_RECT
{
public short Left;
public short Top;
public short Right;
public short Bottom;
}
[StructLayout(LayoutKind.Sequential)]
struct CONSOLE_SCREEN_BUFFER_INFO
{
public COORD dwSize;
public COORD dwCursorPosition;
public int wAttributes;
public SMALL_RECT srWindow;
public COORD dwMaximumWindowSize;
}
[DllImport("kernel32.dll", EntryPoint="GetStdHandle", SetLastError=true,
CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
private static extern int GetStdHandle(int nStdHandle);
[DllImport("kernel32.dll", EntryPoint="FillConsoleOutputCharacter", SetLastError=true,
CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
private static extern int FillConsoleOutputCharacter(int hConsoleOutput,
byte cCharacter, int nLength, COORD dwWriteCoord,
ref int lpNumberOfCharsWritten);
[DllImport("kernel32.dll", EntryPoint="GetConsoleScreenBufferInfo", SetLastError=true,
CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
private static extern int GetConsoleScreenBufferInfo(int hConsoleOutput,
ref CONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo);
[DllImport("kernel32.dll", EntryPoint="SetConsoleCursorPosition", SetLastError=true,
CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
private static extern int SetConsoleCursorPosition(int hConsoleOutput, COORD dwCursorPosition);
public void Clear()
{
int hWrittenChars = 0;
CONSOLE_SCREEN_BUFFER_INFO strConsoleInfo = new CONSOLE_SCREEN_BUFFER_INFO();
COORD Home;
Home.x = Home.y = 0;
GetConsoleScreenBufferInfo(hConsoleHandle, ref strConsoleInfo);
FillConsoleOutputCharacter(hConsoleHandle, EMPTY,
strConsoleInfo.dwSize.x * strConsoleInfo.dwSize.y, Home, ref hWrittenChars);
SetConsoleCursorPosition(hConsoleHandle, Home);
}
}
class Demo
{
[STAThread]
static void Main(string[] args)
{
ConsoleClass ClearMyConsole = new ConsoleClass();
Console.WriteLine("THIS IS FIRST LINE");
Console.ReadLine();
ClearMyConsole.Clear();
Console.WriteLine("THE CONSOLE WAS CLEARED");
Console.WriteLine("Hit Enter to Terminate");
Console.ReadLine();
}
}
}
- Nick Parker My Blog | My Articles
|
|
|
|