|
Does class A : IComparable<A> { } count?
|
|
|
|
|
rights... now i feel stupid... hehehe... got my 5 here... thanks...
think fast, be brave and dont stop.
|
|
|
|
|
How about a factory
public class GenericFactory<T> where T : new()
{
public T Create(){
return new T();
}
}
|
|
|
|
|
no, the guy up there got it... i wanted to see the declared type (itself) being passed back into the generic... (with some sense into it)
think fast, be brave and dont stop.
|
|
|
|
|
------------gL6ei4ae0Ij5ei4ei4Ef1GI3ae0GI3
Content-Disposition: form-data; name="Filename"
[FILE NAME]
------------gL6ei4ae0Ij5ei4ei4Ef1GI3ae0GI3
Content-Disposition: form-data; name="Filedata"; filename="[FILE NAME]"
Content-Type: application/octet-stream
[FILE DATA]
This is a header send by client on file upload. But the problem is that I do not want to use default HttpRequest instance. All I need to get file name and file data. What is best way to parse this. The line index ? Regex ?
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
I have just created a PerformanceCounterCategory which includes various counters type (CounterCreationData), and later using the PerformanceCounter I access to one of this counters in order to operate with them (Increment, IncrementBy ...) but my problem is how to connect my counter to the Monitor (perfmon.exe) included in XP Operative System, I don´t find in it my Category nor counters.
Best Regards
|
|
|
|
|
|
I have datetime field in the table in my database. How to assign that datetime in my local variable ?
i tried
DateTime createdDate;
createdDate = Convert.ToDateTime(result.GetString(1));
but didn't work.
suchita
|
|
|
|
|
What's the value in result.GetString(1)? Try pausing at this line and then see what the data is that's in there.
|
|
|
|
|
its the datetime field.
value is 2010-09-30 11:14:29.783
thanks
suchita
|
|
|
|
|
It sounds to me like there's a culture problem here. In other words, the format on the system doesn't match the format of data in the database.
|
|
|
|
|
yah. I have datetime field in the database. When i am retrieving using datareader, it is taking as string. I think there where the problem is? how to convert that data from the database in to the string value ?
suchita
|
|
|
|
|
|
System.InvalidCastException: Unable to cast object of type 'System.DateTime' to type 'System.String'.
this one is showing as error.
i declare the variable as datetime and string as well but it gave the same error in both. it seems since my datafield is datetime, it is having problem when i am extracting that datetime.
suchita
|
|
|
|
|
SayamiSuchi wrote: but didn't work.
In what way did it not work?
|
|
|
|
|
Assuming that result is a data reader or an sql parameter:
DateTime dateTime = (DateTime)dataReader["columnName"]
or
DateTime dateTime = (DateTime)sqlParameter.Value;
Are the most correct answers. If the field allows null, check for DbNull.Value first.
|
|
|
|
|
ya i already tried this before but it gave the same error.
suchita
|
|
|
|
|
Do not use strings for date/times if you can avoid it, as it opens up a whole range of potential problems. Instead have a datetime field in the database, and a DateTime variable in your code; then do what Ennis said.
If you must use strings, make sure to use a universal format. More is here[^]
|
|
|
|
|
I dont think anyone of you understood my problem. Let me explain again.
I have a table as
CREATE TABLE [dbo].[tblTest](
[ID] [int] IDENTITY(1,1) NOT NULL,
[Date] [datetime] NULL )
Now I am retrieving that value :
DateTime createdDate;
SqlCommand command = new SqlCommand("SELECT ID,Date FROM tblTest WHERE ID = '1'", myConnection);
SqlDataReader result = command.ExecuteReader();
if (result.Read())
{
createdDate = result.GetString(1);
}
when i did this , it gave error.
System.InvalidCastException: Unable to cast object of type 'System.DateTime' to type 'System.String'.
so i declared createdDate as string and tried again. It gave the same error. So I thought its the problem when we are retrieving datetime field from the database. I tried this query in query analyzer, and it is working fine.
I even tried this:
createdDate =(DateTime)(result.GetString(1)); but same error.
suchita
|
|
|
|
|
Damn - I really should read these things through first. Basically, you are trying to read a datetime out as a string here. The code should read
if (!result.IsDBNull(1))
createdDate = result.GetDateTime(1);
|
|
|
|
|
thanks. it worked.
suchita
|
|
|
|
|
|
1: show this result(result.GetString(1));
2: the result fit to time of rule ;
3: String strTime = Convert.ToDateTime(the result fit to time of rule).ToString("yyyy-MM-dd")
4: DateTime dt = new DateTime();
dt = Convert.ToDateTime(the result);
|
|
|
|
|
Try:
DateTime.TryParseExact(....);
See MSDN for details.
V.
|
|
|
|
|
Hi all! I'm writing an Interop wrapper and am wrapping a method that takes an array of objects as a parameter.
void WrappedMethod(object[,] values);
void MyWrapper<T>(T[,] values)
{
WrappedMethod(values);
}
I thought all ref types were also objects, so why can't I cast T[,] to object[,] ?
Thank you all for you time
Matt
modified on Monday, October 25, 2010 4:17 PM
|
|
|
|