|
having the typeof(something), can I create a new (default constructed) instance from that?
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
Yes, see the Activator.CreateInstance method.
-Atul, Sky Software http://www.ssware.com
Shell MegaPack For ActiveX & .Net - Windows Explorer Like Shell UI Controls
|
|
|
|
|
Yes, use the Activator.CreateInstance method.
-Atul, Sky Software http://www.ssware.com
Shell MegaPack For ActiveX & .Net - Windows Explorer Like Shell UI Controls
|
|
|
|
|
|
00001 <br />
00038 #include <stdio.h><br />
00039 #include <sys/types.h><br />
00040
00041
00042 #include "wildmat.h"<br />
00043 <br />
00044 <br />
00045 #define TRUE 1<br />
00046 #define FALSE 0<br />
00047 #define ABORT -1<br />
00048 <br />
00049 <br />
00050 <br />
00051 #define NEGATE_CLASS '^'<br />
00052 <br />
00053 #define OPTIMIZE_JUST_STAR<br />
00054 <br />
00055 #undef MATCH_TAR_PATTERN<br />
00056 <br />
00057 <br />
00058 <br />
00061 static int DoMatch(text, p)<br />
00062 register char *text;<br />
00063 register char *p;<br />
00064 {<br />
00065 register int last;<br />
00066 register int matched;<br />
00067 register int reverse;<br />
00068 <br />
00069 for (; *p; text++, p++) {<br />
00070 if (*text == '\0' && *p != '*')<br />
00071 return ABORT;<br />
00072 switch (*p) {<br />
00073 case '\\':<br />
00074 <br />
00075 p++;<br />
00076 <br />
00077 default:<br />
00078 if (*text != *p)<br />
00079 return FALSE;<br />
00080 continue;<br />
00081 case '?':<br />
00082 <br />
00083 continue;<br />
00084 case '*':<br />
00085 while (*++p == '*')<br />
00086 <br />
00087 continue;<br />
00088 if (*p == '\0')<br />
00089 <br />
00090 return TRUE;<br />
00091 while (*text)<br />
00092 if ((matched =<br />
00093 DoMatch(text++, p)) != FALSE)<br />
00094 return matched;<br />
00095 return ABORT;<br />
00096 case '[':<br />
00097 reverse = p[1] == NEGATE_CLASS ? TRUE : FALSE;<br />
00098 if (reverse)<br />
00099 <br />
00100 p++;<br />
00101 matched = FALSE;<br />
00102 if (p[1] == ']' || p[1] == '-')<br />
00103 if (*++p == *text)<br />
00104 matched = TRUE;<br />
00105 for (last = *p; *++p && *p != ']'; last = *p)<br />
00106 <br />
00107 if (*p == '-' && p[1] != ']'<br />
00108 ? *text <= *++p<br />
00109 && *text >= last : *text == *p)<br />
00110 matched = TRUE;<br />
00111 if (matched == reverse)<br />
00112 return FALSE;<br />
00113 continue;<br />
00114 }<br />
00115 }<br />
00116 <br />
00117 #ifdef MATCH_TAR_PATTERN<br />
00118 if (*text == '/')<br />
00119 return TRUE;<br />
00120 #endif /* MATCH_TAR_ATTERN */<br />
00121 return *text == '\0';<br />
00122 }<br />
00123 <br />
00124 <br />
00125 <br />
00128 int wildmat(const char *text, const char *p)<br />
00129 {<br />
00130 #ifdef OPTIMIZE_JUST_STAR<br />
00131 if (p[0] == '*' && p[1] == '\0')<br />
00132 return TRUE;<br />
00133 #endif /* OPTIMIZE_JUST_STAR */<br />
00134 return DoMatch(text, p) == TRUE;<br />
00135 }<br />
00136 <br />
00137 <br />
00138 <br />
00139 #if defined(TEST)<br />
00140 <br />
00141 <br />
00142 extern char *gets();<br />
00143 <br />
00144 <br />
00145 int main()<br />
00146 {<br />
00147 char p[80];<br />
00148 char text[80];<br />
00149 <br />
00150 printf("Wildmat tester. Enter pattern, then strings to test.\n");<br />
00151 printf<br />
00152 ("A blank line gets prompts for a new pattern; a blank pattern\n");<br />
00153 printf("exits the program.\n");<br />
00154 <br />
00155 for (;;) {<br />
00156 printf("\nEnter pattern: ");<br />
00157 (void) fflush(stdout);<br />
00158 if (gets(p) == NULL || p[0] == '\0')<br />
00159 break;<br />
00160 for (;;) {<br />
00161 printf("Enter text: ");<br />
00162 (void) fflush(stdout);<br />
00163 if (gets(text) == NULL)<br />
00164 exit(0);<br />
00165 if (text[0] == '\0')<br />
00166 <br />
00167 break;<br />
00168 printf(" %s\n",<br />
00169 wildmat(text, p) ? "YES" : "NO");<br />
00170 }<br />
00171 }<br />
00172 <br />
00173 exit(0);<br />
00174 <br />
00175 }<br />
00176 #endif /* defined(TEST) */<br />
<br />
|
|
|
|
|
|
hi this is ravi, i need code for setting our own timimgs in datetimepicker control rather than automatic.
regard ravi
|
|
|
|
|
hi!
I have to convert sqlserver database(table) to an excel file.I tried some code samples available.In some code samples,excel is used as namespace i.e. using excel is mentioned.but I am not able to compile it.please help me if you have any code to convert sql server tables to excel.
Thanking you ,
with regards,
srikanth.
mvssrikanth
|
|
|
|
|
hi!
I have to convert sqlserver database(table) to an excel file.I tried some code samples available.In some code samples,excel is used as namespace i.e. using excel is mentioned.but I am not able to compile it.please help me if you have any code to convert sql server tables to excel.
Thanking you ,
regards,
srikanth.
mvssrikanth
|
|
|
|
|
How do I declare a "Graphics g" inside this event handler?
Graphics g = new Graphics(); //DOESN'T WORK...
private void complexA_OK_Click(object sender, System.EventArgs e)
{
//Want to instantiate a Graphics object here....
}
thanks -- sorry, I know it's a stupid question....if you just want to tell me how dumb I am don't bother responding...
|
|
|
|
|
Write somthing like Graphics g=this.CreateGraphics(); this will get graphics object from the form the event handler belong
if you for example you want to draw in Picture box write
Graphics g=pictureBox1.CreateGraphics();
if you want to Draw on the image to get graphic write
Bitmap bm=new Bitmap(x,y);
Graphics g= Graphics.FromImage(bm);
MCAD
-- modified at 20:42 Friday 2nd September, 2005
|
|
|
|
|
thanks Mohammed, I will try it...
|
|
|
|
|
first of all sorry about my english, but it's all what I have
so, that's the question.
In all controls in the form in properties window (in the bottom right) appears
(DataBindings). What is this and how to use it? I heard that is helps to separate all stuff about how controls react for user's action. I mean, if user click checkbox some text field can be disabled.
|
|
|
|
|
I'm trying to determine the ip assigned by ISP.. so far I've thought of no direct way.. Is there a simple way to get your ip thru c#? not the 192.168.?.? I'm talkin about the external IP... I will continue my search but any links, pointers, similar frustrations would help a bunch
aspiringCodeMonkey says ...
|
|
|
|
|
There is no way of getting the external ip directly. It simply does not exist in the computer.
You have to send a request outside the local network so that the ip number can be detected and sent back to you. For this you need a server that will return the ip number to you.
There are a lot of pages out there that will tell you what ip address you are using. Like Aspsidan/IP[^]. You can use a page like that to get the ip number in the response. Ideal for you would be a page that returns only the ip number in plain text, and nothing else.
---
b { font-weight: normal; }
|
|
|
|
|
|
This is what I want to do:
<br />
abstract class Item<br />
{<br />
abstract Item(int x, int y)<br />
{<br />
x = X;<br />
y = Y;<br />
}<br />
}<br />
class Transistor : Item<br />
{<br />
Transistor(int X, int Y)<br />
{<br />
x = X;<br />
y = Y;<br />
}<br />
}
But it wont work.
How could I solve it?
I got an idea on how to do it...
Like this:
<br />
abstract class Item<br />
{<br />
abstract Item(int x, int y)<br />
{<br />
x = X;<br />
y = Y;<br />
this.init();<br />
}<br />
}<br />
class Transistor : Item<br />
{<br />
init(int X, int Y)<br />
{<br />
}<br />
}
But isn't there a better way?
Niklas Ulvinge aka IDK
|
|
|
|
|
Are you trying something like this?
abstract class Item {
public Item(int x, int y) {
}
}
class Transistor : Item {
public Transistor(int x, int y) : base(x, y) {
}
}
|
|
|
|
|
The incomplete code that you show doesn't tell me what it is that you want to do.
Can you explain what it is that you are trying to accomplish?
---
b { font-weight: normal; }
|
|
|
|
|
I thought I needed to create an instance of item, wich I didn't have to and couldn't do...
I simply removed the construcor and it worked fine.
Thanks for your replies.
I'm tired and can't think really well now, but now is the only time I can program, (at other times it's only homework, school and more homework).
Niklas Ulvinge aka IDK
|
|
|
|
|
best practices of Microsoft recommends the following:
abstract class Item {
protected Item(int x, int y)
{
...
}
}
class Transistor : Item
{
public Transistor(int x, int y) : base(x,y)
{
}
}
Eduardo Diaz
site | english blog | spanish blog
|
|
|
|
|
That was what I'm looking for, thanks
Niklas Ulvinge aka IDK
|
|
|
|
|
I encountered the following problem and I am confused now. I'm sure that cunning foxes are around to help me.
Take this code:
<br />
object o = new object(); <br />
o = 1;<br />
<br />
double dValue = (double) o; <br />
The cast doesn't work and the error message comes up: An unhandled exception of type 'System.InvalidCastException' occurred.
Thanks in advance!
Chris
|
|
|
|
|
object o = new object();
o = 1;
double dValue = Convert.ToDouble(o);
Live Life King Size
Alomgir Miah
|
|
|
|
|
You are boxing an integer into an object. You can only unbox it as an integer:
(int)o
After you have unboxed the value, you can convert it to a double:
double dValue = (double)(int)o;
If you want to store a double in the object, you have to specify that the value is a double:
o = 1d;
---
b { font-weight: normal; }
|
|
|
|