|
yes...Coding today is almost too
easy with all the help availible
in realtime...;)
|
|
|
|
|
Unfortunately the other solutions will fail under other cultures. Do the following instead:
double x = 33.452;
Console.WriteLine(x % Math.Floor(x));
|
|
|
|
|
This works for any culture. It also handles the case where there is no fractional digits, instead of causing an exception.
double x = 33.452;
string number = x.ToString(CultureInfo.InvariantCulture);
int pos = number.IndexOf('.');
if (pos == -1) {
Controle.WriteLine();
} else {
Console.WriteLine(number.Substring(pos + 1));
}
---
b { font-weight: normal; }
|
|
|
|
|
I've got an app as described in the subject. I am trying to write an update class that will handle changes to the database structure. I can figure out how to create a new tables using "CREATE TABLE" statements with the ODBCCommand object. What I cannot figure out is how to set field properties. Anything other than the basic (fld_name fld_type,...) statements result in an "[Error 42000] Syntax error in CREATE TABLE statement".
Mostly what I'd like to be able to do is set default values and create auto-number fields. If anyone can give me a bit of guidance on this or direct me to a useful link, I'd greatly appreciate it.
TIA,
Eric
|
|
|
|
|
How would I go about finding the free space on a given disk?
Thanks for any help.
|
|
|
|
|
check out 'DriveInfo class' in
the help menu. The sample seems
to be what you need.
gl-Paul
|
|
|
|
|
Yup, exactly what I need.
Thanks
|
|
|
|
|
Hi,
I'd like to make a listbox display multilines to user without using scrolldown when another event is clicked. And the same listbox shows only one item when another event is clicked.
Ex: when you click a button A, then a listbox B shows multilines of items.
And when you click the button A again, the listbox B shows only one line.
Thanks.
Kyah
|
|
|
|
|
Do you prefer any address about this algorithm or do you have any source code about them.
Thank you.
|
|
|
|
|
Are you trying to simulate multitask scheduling, or are you trying to apply these concepts to real task queue processing?
--
I've killed again, haven't I?
|
|
|
|
|
real task queue processing
|
|
|
|
|
I am using some functions available in wininet.dll to monitor, dial and hangup internet connections from my C# application.
here I have some questions:
1)Is it true that .Net Framework 2 hasn't some functionality for the same?
2)I'm using the InternetDial function of this API to connect to Internet. This function has a pointer to a connection number, so when I have to HangUp the connection I use InternetHangUp which also uses the above connection number to shut this connection down.
however I couldn't find a way to get the connection number of an already active connection, when my aplication goes on-line and have the possibility to hang-up this active connection.
So, the question is of course:
does anybody knows how to check or get this connection number?.
So far for me,the only two functions make use of this connection number are InternetDial and InternetHangUp, not so the also useful function InternetGetConnectedState which is capable to say that there is an active connection but not which connection number this connection has.
Thanks in advance
-- modified at 14:57 Friday 10th March, 2006
|
|
|
|
|
i've inherited a projects that uses a BindingList to hold DB records. i want to be able to sort the items in the BindingList.
the code for the BindingList-derived class has FindCore, SearchCore and all the things I assume are required to do the sorting. but, i simply cannot figure out how to call it.
ex. the FindCore member looks like this:
protected override int FindCore(PropertyDescriptor property, object key)
{
if (property == null) return -1;
List<T> items = this.Items as List<T>;
foreach (T item in items)
{
string value = (string)property.GetValue(item);
if ((string)key == value) return IndexOf(item);
}
return -1;
}
my problem is... i don't know enough C# to know how to create that PropertyDescriptor object in order to tell the function to search the contained items on a given property.
i've found a dozen articles on the web that tell me how to write the FindCore function, but none that show how to call it.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Hi
Have a look at the TypeDescriptor.CreateProperty method.
----------------------------
Be excellent to each other
|
|
|
|
|
thanks, but that's just another maze i can't find my way out of.
what's the "Attribute" parameter for ? how to specify the Type ? etc..
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Hi
This might help:
Item class:
public class Class
{
public string Property { get { return "hello"; } }
}
MyBindingList:
public int Find( string key )
{
PropertyDescriptor property =
TypeDescriptor.CreateProperty(
typeof( Class ),
"Property",
typeof( string ) );
return FindCore( property, key );
}
Call:
private void button1_Click( object sender, EventArgs e )
{
int i = _List.Find( "hello" );
}
Hope this helps
----------------------------
Be excellent to each other
|
|
|
|
|
|
Hi
Does any one has tutorial, which show how to build DotnetNuke module using C# 2.0
Regards,
chandana
|
|
|
|
|
Virtually all documentation for DNN is using VB.NET. However, the principles are exactly the same. The Framework is the same, the portal software is the same, there is only a difference in about 100 keywords in the language (many of which are are the same, but with different capitalisation). It should therefore not be too difficult to work out what to do in C#.
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
Hello,
I have a question about the FileInfo object: I'm wondering if anyone eles has experienced this issue.
I'm currently working with Visual Studio 2005 and the .NET Framework 2.0. I just finished debugging a small portion of my code and I noticed the following issue. The FileInfo.Exists property was returning false even when the file did exist on the file system. Here's how I got this to occur:
using System;
using System.IO;
namespace TestCode {
static void Main(string[] args) {
// Construct the FileInfo object
FileInfo someNewFile = new FileInfo( @"C:\myNewFile.txt" );
// Create a new file after creating a FileInfo object
FileStream fs = new FileStream( @"C:\myNewFile.txt", FileMode.Create, FileAccess.ReadWrite,
FileShare.None );
// Create some erroneous data and write it to the file
byte[] bytes = new byte[1] { '\0' };
fs.Write( bytes, 0, 1 );
// Flush and Close the FileStream
fs.Flush();
fs.Close();
// --------- ERROR --------------
// Note the following error: someNewFile.Exists returns FALSE
bool exists = someNewFile.Exists;
Console.WriteLine( "someNewFile.Exists returned " + exists );
}
}
So as you can see, I created the file after instantiating the FileInfo object. I checked the MSDN Documentation for Visual Studio 2005 and did not find any mention of this behavior, so... I'm wondering:
1. Has anyone else experienced this issue?
2. Can this be recreated on someone else's computer with the above code?
3. Is this intentional and simply not documented anywhere?
Thanks!
-Christian
|
|
|
|
|
I believe this is by design, with the the file info class containing static data from instanciation rather than taking the overhead needed to monitor the filesystem for any changes. If you need dynamic updates you'll have to run a FileSystemWatcher in a seperate thread to do the updating, and even then you'll have a slight delay due to when the FSW thread gains a CPU to do it's work.
|
|
|
|
|
Maybe you should first create the file itself and the FileInfo object afterwards cause probably the Exists property determines its return value on basis of information from construction time and not invocation time.
www.troschuetz.de
|
|
|
|
|
Use the Refresh method to update the information in the FileInfo object.
If you use the FileInfo object to create the file, I believe that it will update itself, but if you create the file "behind it's back" it won't be aware of the change, and will return the information that it got when it was created.
How this works is mentioned in the documentation for most of the properties of the object, but not in the documentation of the Exists property.
---
b { font-weight: normal; }
|
|
|
|
|
This is probably not related, but it could be security restrictions on the computer.
Today i wrote some code on a computer that should of worked...the file most definately existed at the path, but creating a stream to the file and testing if it existed with File.Exists kept on reporting that the file did not exist...even though Assembly.Load on a file, even though the file existed,and
Directory.GetFiles showed it...
Look here was the output,...the paths in beginning were files in directory
<br />
C:\Documents and<br />
Settings\jah4\Desktop\Projects\WindowsApplication1\bin\Debug\ClassLibrary1.dll<br />
C:\Documents and<br />
Settings\jah4\Desktop\Projects\WindowsApplication1\bin\Debug\ClassLibrary1.pdb<br />
C:\Documents and<br />
Settings\jah4\Desktop\Projects\WindowsApplication1\bin\Debug\WindowsApplication1.exe<br />
C:\Documents and<br />
Settings\jah4\Desktop\Projects\WindowsApplication1\bin\Debug\WindowsApplication1.pdb<br />
<br />
File or assembly name C:\Documents and<br />
Settings\jah4\Desktop\Projects\WindowsApplication1\bin\Debug\ClassLibrary1.dll,<br />
or one of its dependencies, was not found.<br />
So it turned out some security thing prevented me from loading a file...theirs probably some api i could dllimport to get around that bug , at the very least i could just run notepad which has the sorta access i need to read the file...then to a byte array and my Assembly.Load would probably work...but i'm to lazy for that
|
|
|
|
|
Hi again
Sorry - Forgot to mention that the last post is for compact framework.
Thanks
|
|
|
|