If you have a custom collection class that stores the weights of a single class of fruits individually in floats/double, like so:
1.1, 3.3, 6.6, 4.4, ...
and you would need to specify whether it's float or double and to differentiate the fruit type, is it better to do it like this:
Using an enum:
FruitList<float, FruitType.Orange>
...
If I have a form with controls DataBound to an instance variable object, is there a way to do revert changes that the user made, possibly by doing something like:
myLocalObject = DataLayer.GetCurrentState();
and have the form's controls (bound to myLocalObject) automatically pick up the changes?
Thanks!
...
I have a method like:
AverageAndDoSomeMath (Point2)
and I wonder how to handle:
AverageAndDoSomeMath (Point2) // single
AverageAndDoSomeMath (Point2 collection) // multiple
using a single implementation preferably.
For collection, I plan to use the IEnumerable type so I can pass any kind of collection, but for a single value, I do...
We are trying to copy a file from a server, down to a local machine in a .NET 2.0 application (C#), but keep having the source file unnecessarily locked. We suspect it is something configured on the file server that is causing this behaviour, but are not sure what ... can you help?
After the file copy operation, the file server (Windows...
I've been trying to create a simple base class that encapsulates some of my conventions for database access. I generally create a sproc named "products_retrieve_product" to select a product based on productID. I would like the method "Retrieve" in the base class to return the type that the derived class supplies in it's definition. I...
If you have several classes where you want them to inherit from a base class for common functionality, should you implement the base class using a class or an abstract class?
...
A few words about an ongoing design and implementation
I send a lot of requests to the remote application (running on a different
host, of course), and the application send back data.
About client
Client is a UI that spawn a separate thread to submit and process the requests. Once it submits all the requests, it calls Wait. And the ...
I encountered what may be a leap year in .NET's DateTime handling, specifically ToLocalTime(). Here's some code which reproduces the problem (I'm in the Pacific time zone):
DateTime dtStartLocal = DateTime.Parse("2009-02-28T23:00:00.0-08:00");
DateTime dtEndLocal = dtStartLocal.AddYears(3);
DateTime dtStartUtc = dtStartLocal.ToUniversa...
I have some developers who are rather green when it comes to object oriented development, and I was looking for a way to explain to him the concept of casting and a few other things. I was doing a code review on some of his code and I find things like
protected Guid LastValue {
get {
if (ViewState["LastValue"] == n...
Are there any industry standard formulas or rules of thumb for determining:
Application bandwidth usage/requirements
Database growth requirements
I have recently started managing a new .NET 3.5/SQL Server project and would like to take a more structured approach than previously when determining exactly what my application needs in te...
I am wondering if there are any differences to derived classes when using abstract vs real classes for inheritance?
It looks to me like the real class inheritance creates an hierarchy whereas abstract class inheritance is just copy-paste code for the compiler to derived classes?
Does the abstract class creates a hierarchy? Can it be ac...
I need a data structure that holds a list of elements of the same type. Needed features are
Add
GetEnumerator
(may be) Clear
An indexed access, sorting, searching, removing of elements are not required. What is the best collection class for it? The following aspects should be taken in consideration: performance, memory usage, behavio...
I'm trying to get simple encryption/decryption working with AesManaged, but I keep getting an exception when trying to close the decryption stream. The string here gets encrypted and decrypted correctly, and then I get the CryptographicException "Padding was invalid and cannot be removed" after Console.WriteLine prints the correct strin...
I can't seem to get PdfSharp to show a picture for this annotation. It doesn't have the PdfAnnotation.Icon property, so I can't set that.
XFont font = new XFont("Verdana", 10);
PdfPage page = wDoc.Parent.Page;
XGraphics gfx = wDoc.Parent.gfx;
XRect rec = gfx.Transformer.WorldToDefaultPage(new XRect(new XPoint(30,...
I have worked on several applications that saved XML data into a database. To date all of them simply overwrote the current XML contents with the new XML contents.
I would like to save the changes to the XML to the database but not overwrite what is currently in the DB.
Short of just creating new rows for changes and leaving the old...
I am looking for a .NET library that is able to decode data from a PDF-417 barcode that is embedded either in an image file or PDF. At this point, I have only been able to find a Java version and a C version.
Ideally, this library would be both open-source and free of charge, but I doubt such a decoder exists.
I am open to trying out...
Hi im thinking about developing a sort of File Transfer program and was wondering if i want as good encryption that i can get what should i use?
ill be developing this with c# so i got access to the .net lib :P
having a certificate with me on my usb to access the server is no problem if that would increase the security!
...
I want to capture a keyboard shortcut in my application and trigger a dialog to appear if the user presses a keyboard combo even outside of the app. Similar to Google Desktop Search's Ctrl, Ctrl to bring up the search dialog.
I have tried using some keyboard hook modules out there that basically use Win32 interop to get this effect but ...
Hi,
In this code, I'd like the ReadFileSystem method to be forbidden to Assert a permission on the filesystem.
I expected this will throw at fileIo.Assert(), but it doesn't. Why?
using System.Security.Permissions;
static void Main(string[] args)
{
var fileIo = new FileIOPermission(PermissionState.Unrestricted);
var secuPerm = ...
I'm curious what everyone does for handling/abstracting the QueryString in ASP.NET. In some of our web apps I see a lot of this all over the site:
int val = 0;
if(Request.QueryString["someKey"] != null)
{
val = Convert.ToInt32(Request.QueryString["someKey"]);
}
What are some better ways to handle this grossness?
...