|
See the BitConverter class in the .NET Framework SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
My class has a structure as such:
public class MyClass{
MyNestedClass Property1;
string Property2;
(... other members ...)
protected class MyNestedClass{
string PropertyA;
string PropertyB;
(... other members ...)
}
}
The reason behind encapsulating PropertyA and PropertyB is because I use the two properties more often than the other members in MyClass, even though PropertyA and PropertyB belong (describe) MyClass. That reason seems to be good when it comes to implementation.
However, somehow I don't think it is conceptually correct because I believe that a class should describe a complete entity.
I appreciate any comments.
|
|
|
|
|
Hi,
I am trying to create a login page.
Can someone point out to me how I may connect to a back-end Access database, and validate the entered username and password with the ones stored in the database?
Thanks for any help in advance
|
|
|
|
|
See my article, Role-based Security with Forms Authentication[^], for information on how to use a database to store and validate credentials using Forms Authentication, which provides many features over most home-brewed solutions (which are typically pretty insecure if you don't have a lot of experience with security).
The .NET Framework 2.0 will make this even easier with pluggable authentication back-ends to various front-ends (like Forms Authentication). For now, you're pretty much left with either extending what's available or implementing your own authentication modules.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Making my application i have suddently got and evil optimization question about "What are the internals of the array list" . Does any of you know if it is based on a linked list or on an array.
Also do you know where i can get my hand on a Simple Linked List or a Binary Tree.
Thank you for help.
|
|
|
|
|
An ArrayList is an array that grows dynamically by recreating the array (often doubling the size) everytime the bounds are surpassed.
As far as binary trees go, I suggest you take a peak at the MSDN article[^] regarding data structures. Part 3[^] of the article shows off some trees, including the source for a binary tree in C#.
---------------------------
He who knows that enough is enough will always have enough.
-Lao Tsu
|
|
|
|
|
As Judah said, it uses a new array that typically doubles whenever the Capacity is reached.
To note, the ArrayList is used internally by many collections, so don't think you can escape it so easily!
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank both of you.
I have another little question. What is the perforamce loss due to the type casting of array list elements. If my array list contains the same type elemets (or which share the same base class), could i use something equivalent to templates in C++.
Thank again.
Anton.
|
|
|
|
|
An ArrayList stores object s, so if you add reference types to the list, there's really no performance hit (1 to 2 extra instructions are required to cast, and optionally store, your type, but that's negligible). If you store value types, there is a slight performance hit because value types must be boxed and unboxed to store as an object . This is one of many reasons why generics will be great to have in the upcoming .NET Framework 2.0. Then you can declare a new list of value types, like List<int> ints = new List<int>(); .
This (un)boxing is typically not too big a problem if you don't use it a lot and don't need to milk your app for performance for every last drop. If you do, then you might consider implementing your own ArrayList -like class, implementing all the same interfaces (for the best support) and keep an array of whatever value type you need. Grow it when needs be, just like the ArrayList would.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
In this case i will keep it, since making changes later would be much easier.
Thank you.
|
|
|
|
|
I have several images that have text on them, they are instructions that were turned into jpegs. Here is the question is there a way to de-construct the image so I can get just the text?
The reason for this insanity is reports. I have a report that "could" have lots of image data and as we all know there is no good way to split an image for a page break. Is there a good way to do this?
I will be coding for IE 6 only as this is an internal project, so x-browser solutions are not required .. but always welcome..
Any help on this would be great.
Thanks
William O'Malley
|
|
|
|
|
|
thank you for the article reference. very interesting stuff.
How ever I really don't have the money to spend on a third party add in. I was really hoping that I could find a way to do this with out using a third party add-in
thanks
William O'Malley
|
|
|
|
|
You don't need third-party software: the article describes how to create your own OCR scanning solution. However you implement, the concepts around OCR are your solution.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hi,
i use cards.dll to draw cards in my app.
and it works good in onpaint method
for example:
<br />
Graphics x = e.Graphics;<br />
<br />
hdc = x.GetHdc();<br />
x.ReleaseHdc(hdc);<br />
cardHandle.drawCardBack( hdc, 90, 10, eBACK.WEAVE1 );<br />
but if i try do the same thing offscreen, it does not work!
can someone explain why?
<br />
Bitmap offScreenBmp = new Bitmap(this.Width, this.Height); <br />
Graphics offScreenDC = Graphics.FromImage(offScreenBmp); <br />
<br />
hdc = offScreenDC.GetHdc();<br />
offScreenDC.ReleaseHdc(hdc);<br />
cardHandle.drawCardBack( hdc, 90, 10, eBACK.WEAVE1 );<br />
e.Graphics.DrawImage(offScreenBmp, 10, 10);<br />
I need it to rotate this card.
I have tried this method, but it does not worke.Graphics.RotateTransform(90f);
if u know another way how to rotate the card i draw with cards.dll, please tell me
thank u
|
|
|
|
|
It probably doesn't work because you're releasing the HDC before you use it. Release it afterward. Once you've drawn to an off-screen bitmap, you should have no problems rotating it.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
oh, u r right, it works!
but, what's about this first example?
it seems as if it works pretty good!
|
|
|
|
|
Surprising that it does, but you really shouldn't release the HDC until you're done (that's how it supposed to work).
See the native CreateCompatibleBitmap API. You probably need to create a bitmap that is compatible (i.e., supports the same capabilities) with the on-screen bitmap, which is usually the case in GDI. You might be able to accomplish this by using Graphics.FromHdc to get a Graphics object, then use Clone to clone it. I've never tried it this way, but GDI+ is usually as simple as this.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I need to know what is the fastest and most efficient way to upload large files (4mb to 50mb) from a c# windows form app to a win2k server. I've run into memory issues on my server with files larger than about 8m (iis caches the entire file uploaded as a byte array before writing to disk ... this causes the server to hang) and need to implement a solution to this problem.
I've fished around for a chunking solution (send the file up in, say, 500k chunks and rebuild the file on the server) but cant find any code examples on how to do this.
Any help would be greatly appreciated.
Rob
(first time poster, long time reader )
|
|
|
|
|
Sorry, but what's wrong with the System.IO.File.Copy method?
I see dumb people
|
|
|
|
|
The upload is from a windows form application to a win2k server over the internet, so its not a simple file copy over an internal lan.
|
|
|
|
|
See the class documentation for the HttpFileCollection class. You can use a simple HttpWebRequest to get the request stream and write one or more files using multipart-MIME to a Page (.aspx file). This is receieved as an HttpFileCollection which you can use to write each individual file to disk. This is a byte-for-byte copy.
If you're using Web Services or .NET Remoting, you can use DIME, for which more information can be found at http://msdn.microsoft.com/library/en-us/dnservice/html/service01152002.asp[^]. This is much faster than sending encoded byte[] arrays using SOAP.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
DIME is not an option given some of the client computers are win98.
I did some preliminary investigation into remoting and read somewhere about remoting being faster for small binary file transfer than SOAP but poor for large files ...
(btw i thought DIME used SOAP and not .net remoting ...?)
Thanks all for your speedy replies ... way faster than any of my newsgroup posts!
Rob
|
|
|
|
|
Neither DIME nor SOAP uses .NET Remoting - .NET Remoting (and Web Services) use DIME and/or SOAP (Remoting can also use other formatters).
While DIME is related to SOAP in that it's a solution to a problem, it's not really tied to it. DIME is simply prepending the actual bytes to the SOAP message and referring to it in the SOAP message body.
I'm not sure where you got that DIME doesn't work with Win98/ME. If the implementation requires it for some functionality, nothing's stopping you from implementing it yourself without such a requirement (which I've never seen, BTW). DIME is a specification. The WSE (Web Service Enhancements) supports it, but you can make your own implementation. There's plenty of conceptual and technical documentation on it, including the specification itself (don't remember where, but it'll be linked in various articles - probably on W3C[^]).
Also, if all you're doing is uploading files to a web server, you could always just stick with simple HTTP POST. It's easy. If you are needing this for a Web Services or .NET Remoting, you could always have the page that accepts the post return a cookie (not necessarily the HTTP kind - just a token that is associated with an operation) that you pass to the WS or Remoting object that identifies the group of files (perhaps stored in a file, database, or some session- or application-level cache if using the same AppDomain for the site and WS or Remoting host).
The simple point is that you want to avoid having to encode the byte[] array because its slow (typically, base64 encoding is used but this can be changed using variousing binding flags for the SoapFormatter ). If you use a BinaryFormatter as the format to be sent across the wire, you don't have to worry about this encoding problem (and its better for any size of file - or data, for that matter, but not always desirable because of interoperability with other platforms).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Sorry ... I meant the Web Services Enhancement for .NET from Microsoft does not run on a Win98 system (2k+ or XP only)
If you could point me to where I can find infor on DIME on a Win98 box that would be great!
Interoperability is not a problem given I control both ends of the system.
BTW I did implement uploading to a multipart/form-data page from my winform client but found it killed the server when the upload size exceeded 8mb .. asp.net caches the entire file to memory before writing to disk. Thats when i began to look into a chunking solution and then thought maybe theres even a better way to fire up these files to the server ...
Thanks Heath ... you've been most helpfull ... really appreciate it!
Rob
|
|
|
|