|
Create a DateTimeFormat object and set the custom format on that, then you can use it to format and parse strings.
For time zone convertsion, look into the TimeZone class.
---
b { font-weight: normal; }
|
|
|
|
|
I am. My main form constructor calls this code:
<br />
System.Globalization.CultureInfo info;<br />
info = System.Globalization.CultureInfo.CurrentCulture;<br />
info = new System.Globalization.CultureInfo(info.LCID, true);<br />
info.DateTimeFormat.ShortTimePattern = "HHmmss";
info.DateTimeFormat.LongTimePattern = "HHmmss";
info.DateTimeFormat.ShortDatePattern = "yyyyMMdd";
info.DateTimeFormat.FullDateTimePattern = "yyyyMMdd HHmmss";
System.Threading.Thread.CurrentThread.CurrentCulture = info; <br />
<br />
DateTime test = Convert.ToDateTime("20060109 170501");<br />
The converions call on the last line throws a System.FormatException: {"String was not recognized as a valid DateTime." }
|
|
|
|
|
Odd, I really thought that would work. Perhaps it's the tricky date format.
You can use ParseExact:
DateTime test = DateTime.ParseExact("20060109 170501", "yyyyMMdd HHmmss", null);
---
b { font-weight: normal; }
|
|
|
|
|
That way worked. I'm going to kick the convert problem over to the MSbug tracker and see what they say. I can't see any way they could call this behavior a 'feature', then again Ctrl key shortcuts working for invisible menu items apparently are, and weren't changable because it might break intended functionality in an existing app. Anyone intentially using that behavior deserves to have more than just thier app broken, IMO.
|
|
|
|
|
Guffa wrote: For time zone convertsion, look into the TimeZone class.
That looks like it covers most of what I want, there doesn't appear to be a way to set the app to always read/write/display in a TZ other than the system default. The number of places where I'm using date/times is small enough that it's not a prohibitive change to hardcode them seperately, but I prefer not to do so whenever possible.
|
|
|
|
|
I need writing to COM port (COM1 for example) to send AT commands to modem, please help me doing that. I heared, that i can open COM as a file and write into it, but when i tryed this in C# - an error occured: "FileStream will not open Win32 devices such as disk partitions and tape drives".
Help me please.
Thanks.
SAns
|
|
|
|
|
Use the SerialPort[^] class.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
|
Thanks, I'm allready solve this problem: I used "http://www.gotdotnet.com/Community/UserSamples/Download.aspx?SampleGuid=FCBA7FC5-666E-4EB0-863F-0045B0C79EC7" SerialStream Class, but I'll see your classes too.
SAns
|
|
|
|
|
hi,
I am trying to display status of the application using ToolStripStatusLabel.
it works fine but the problem is if the status message is longer than the length of the label itself then it does not display the status message info.
will really appreciate your help.
rnv
|
|
|
|
|
Hi,
I have a class library in C#.This dll will reside on mobile or PDA device.
the device will be connected to PC using active sync.I want to call functions inside this DLL from client running on PC.Is there any way to achive this ,since class library doesn't export any functions?
|
|
|
|
|
Features not supported in .Net Compact Framework
Being a subset of .Net Framework, not all features are supported by .Net Compact Framework. Following are some key features that are missing in compact framework.
[Reference 2]
1. ASP .Net: Primarily being a rich client platform, it doesn’t provide any ASP .Net support.
2. Assemblies and GAC: There is no support for multimodule assemblies.
3. COM Interoperability: Even though interoperability with COM objects is not supported, there are other ways of accessing a COM object. Platform Invoke method can be used to call native DLLs which in turn can access COM DLLs.
4. Asynchronous Delegates: Not supported.
5. Reflection: No support for System.Reflection.Emit namespace.
6. XML Web Services: Developers cannot host web services under .Net Compact Framework.
7. Remoting: Cannot develop Remoting applications.
8. Printing: No support for printing functionalities.
9. GDI+: Advance GDI support is missing in Compact Framework.
10. XML: XML Schema validations and XPath are not supported.
Taken from:
http://www.c-sharpcorner.com/Code/2004/June/DevelopCFApps.asp [^]
I'm in the high-fidelity first class traveling set.
And I think I need a Lear jet.
-- modified at 9:49 Monday 9th January, 2006
|
|
|
|
|
my dataTable has columns ID and Name
in my datagrid i have hidden Column Id and only display Column Name
code in C#
table.Columns["Id"].ColumnMapping =MappingType.Hidden;
datagrid.DataSource =table;
how can i access my Column id
i have tried
DataTable tb =(DataTable)DataGrid.DataSource;
DataRow row =dt.Rows[0];
decimal id =(decimal)row[1].ToString();
olny get errors
thanks
regards paula
|
|
|
|
|
This is because row[1].ToString(); return a string which cannot be cast to decimal . If the column is of type decimal then try decimal id =(decimal)row[1]; or even better (as it works with any numerical values) decimal id =Convert.ToDecimal(row[1]);
And in future please post the error message you get (and exactly where it occurs).
|
|
|
|
|
I have Header User control (which contains ASP DropDownList with AutoPostBack Property True) and WebForm1.aspx page in my application. Header1.ascx user control embedded with WebForm1.aspx page. Now if I choose the items in DropDownList which is in Header1.ascx the WebForm1.aspx page load event fires first and then the Header1.ascx Page load event fires. But I am assigning session value in Header1.ascx page. So all I want is the header1.ascx page load should fire first then the webform1 page load event or else the before the webform1 page load event get fires I want to assign the value to the session. How do I resolve this?
In Header1.ascx page load event I have write the following:
If (IspostBack)
//assigning session value
DropDownList1_SelectedIndexChanged event
//assigning session value
|
|
|
|
|
Hi Karthi,
Change private to public (private void Page_Load(object sender, System.EventArgs e) to public void Page_Load(object sender, System.EventArgs e)). On webpage page_load event create an instance for your control(webusercontrol1 wc = new webusercontrol1()) and we can fire the usercontrol page_load event by using the instance variable (wc.Page_load(sender, e)). Let me know your comments if you have any queries in this code.
Thanks
Warm Regards
Prakash-B
|
|
|
|
|
I'm working on WSe 2.0 and while calling some function say CreateApplication, I'm receiving following error.
System.Exception was unhandled
Message="WSE104: An asynchronous callback raised an exception."
Source="Microsoft.Web.Services2"
StackTrace:
at Microsoft.Web.Services2.AsyncResult.RaiseUnhandledException(Object
o)
at
System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at
System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)
Inner exception says:
"Could not find any resources appropriate for the specified culture or the neutral culture. Make sure \"Microsoft.Csf.SDK.Microsoft.Csf.SDK.resources\" was correctly embedded or linked into assembly \"Microsoft.Csf.Sdk\" at compile time, or that all the satellite assemblies required are loadable and fully signed."}
I'm using win 2k3 server with SP1 installed and .NET 2.0 to call the method. Do anybody have any idea what could be the possible reason. I've done lot of search on net and applied all solutions like increasing execution time and other time spans. But I'm still facing the same error. Also the error occurs only when I call the function from other machine. On the same machine if i execute the same code it works without any error. Can anybody help me out in this case?
Really there is no material available on net.
Regards
Jayant D. Kulkarni
Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET
|
|
|
|
|
i have project about image processing. I have most of them but at the end i will show two images. One of the image is 5 mbyte jpeg and i dont want to refresh it, and other image contains only lines about the first images. i search most the image processing project.
At the end i will explain from another sight. I will use two image box layer. One of them shows the image which has very big file size. And other image box works as transparent image box. This image box contains only lines, and i will refresh it very frequently.
I try different approach to this problem but it always flickiring because of the image size is very big when it is opened in the ram area.
Is there anybody help me : ;P;)
thanks
-- modified at 9:32 Friday 13th January, 2006
the question is, how can i create a transparent image box ?
|
|
|
|
|
Out of sheer curiosity I have a quick question relating to C# performance. I have the two following methods:
public static string VerboseProgrammingMethod()
{
System.Guid g = Guid.NewGuid();
string s = g.ToString();
string f = s.Substring(0,4);
return f;
}
public static string OneLineProgrammingMethod()
{
return Guid.NewGuid().ToString().Substring(0, 4);
}
As you can see both of them will generate exactly the same output as they essentially perform the same functions. The question is is one of them quicker/less memory intensive than the other?
I am under the impression that it doesnt make any difference whatsoever, but I would be grateful if somebody could confirm this
|
|
|
|
|
run an app called ildasm from the VSNet command prompt and open your assembly with both methods in.
You should see that the generated IL is exactly the same.
|
|
|
|
|
The first methods creates two strings(s,f) and it should be more memory consuming.
|
|
|
|
|
I'm afraid that's not true, since the resulting IL is identical.
Regards,
mav
|
|
|
|
|
The two strings are created in both codes. The only difference is that the references to the strings are declared as variables in one code, while in the other code the compiler will create the references itself to handle the strings.
---
b { font-weight: normal; }
|
|
|
|
|
Like the others say, both are the same. #1 is must easier to debug though, and should allways be used (for clarity too). Make a habit of it. We are proffesionals, not script kiddie/wannabe hackers
NOTE: That saying, I still take the 'short' route sometimes
xacc.ide-0.1.1.4 - now with LSharp integration and scripting :)
|
|
|
|
|
I totally agree with your professionals vs script kiddie comment, but on occasion it is sometimes necessary to make sacrifices for performance.
As suggested by Jamie4C I created the following class library and ran it through ILDasm
public class Class1
{
public static string VerboseProgrammingMethod()
{
System.Guid g = Guid.NewGuid();
string s = g.ToString();
string f = s.Substring(0,4);
return f;
}
public static string OneLineProgrammingMethod()
{
return Guid.NewGuid().ToString().Substring(0, 4);
}
}
}
Now in theory the IL code for these two functions should be exactly the same, interestingly there are differences. I am no IL expert so this might be a red herring, but here is the IL code:
.method public hidebysig static string VerboseProgrammingMethod() cil managed
{
.maxstack 3
.locals init ([0] valuetype [mscorlib]System.Guid g,
[1] string s,
[2] string f,
[3] string CS$00000003$00000000)
IL_0000: call valuetype [mscorlib]System.Guid [mscorlib]System.Guid::NewGuid()
IL_0005: stloc.0
IL_0006: ldloca.s g
IL_0008: call instance string [mscorlib]System.Guid::ToString()
IL_000d: stloc.1
IL_000e: ldloc.1
IL_000f: ldc.i4.0
IL_0010: ldc.i4.4
IL_0011: callvirt instance string [mscorlib]System.String::Substring(int32,
int32)
IL_0016: stloc.2
IL_0017: ldloc.2
IL_0018: stloc.3
IL_0019: br.s IL_001b
IL_001b: ldloc.3
IL_001c: ret
}
.method public hidebysig static string OneLineProgrammingMethod() cil managed
{
.maxstack 3
.locals init ([0] string CS$00000003$00000000,
[1] valuetype [mscorlib]System.Guid CS$00000002$00000001)
IL_0000: call valuetype [mscorlib]System.Guid [mscorlib]System.Guid::NewGuid()
IL_0005: stloc.1
IL_0006: ldloca.s CS$00000002$00000001
IL_0008: call instance string [mscorlib]System.Guid::ToString()
IL_000d: ldc.i4.0
IL_000e: ldc.i4.4
IL_000f: callvirt instance string [mscorlib]System.String::Substring(int32,
int32)
IL_0014: stloc.0
IL_0015: br.s IL_0017
IL_0017: ldloc.0
IL_0018: ret
}
-- modified at 7:02 Monday 9th January, 2006
|
|
|
|