.net

Creating custom events - Object Sender or Typed Sender?

I searched through the archives and I found lots of questions about what sender is and why you should use the pattern but I didn't see anything about a custom event and the type if sender. Say I am creating a custom class called Subscription and it implements ISubscription and I have some event args called SubscriptionEventArgs. If Subs...

Get first and second cell of every HTML table row

I'm trying to get just some specific cells in each row using HTMLAgilityPack. foreach (HtmlNode row in ContentNode.SelectNodes("descendant::tr")) { //Do something to first cell //Do something to second cell } There are more cells, and each cell needs some specialized treatment. I guess there's a way to do this using XPath, but...

How can I convert an image to an ASCII representation of the image?

My idea is to grab each pixel, analyze the 255,255,255 value and give each pixel a chance to be in only 1 of 10 division I will have laid out. This won't bring a full color representation, but my point is to make a ASCII that at least resemble the shapes of the objects in the pictures. Outline it so to speak. Would this work? ...

LinqToXml OR Xml ?

Hello everybody I am trying to processing on xml and i am so tired to work with Xml namespace classes. I found it really hard. So i am trying to do same things with LinqtoXml classes and i see that many things possible with LinqtoXml instead of Xml classes. So i really get confused which i have to use. When and why do u prefer Xml ...

AppendChild and Specified method is not supported exception .

Below code gives this error message "Specified method is not supported". But here is sample which is same with mine. FileInfo file = new FileInfo("../../file.xml"); XDocument xfile = XDocument.Load(file.FullName); XPathNavigator nav = xfile.CreateNavigator(); nav.AppendChild("<pages>100</pages>"); ...

Why are positional and named parameters for attribute types limited to the attribute parameter types?

Why are positional and named parameters for attribute types limited to the attribute parameter types? Background: I'd like to supply functionality at runtime to an attribute. The only way I can see of doing so is to supply a System.Type which I then use to access the required functionality using something like Activator.CreateInstance w...

Using the "right" .NET Framework version

Which version of .net framework to choose to work on? Let's say if you are creating an application and are familiar with .net 1.1 and all your application's functionality can be built on top of the .net 1.1 but voila there are newer versions as well upto 4.0 so in this case which version you will choose to start with? When it comes to d...

How can I get the width and height of an Image?

My plan is to load a picture from a users hard drive and then do some wizardry on it in memory. First thing is first, how can I get the height and width from an Image? Also, say I wanted to select a rectangular piece from the image, how would I do that in memory (no GUI)? Thank you for your guidance. ...

Multiple seach paths for assemblies not in the GAC when using REGASM & COM

I am in the process of creating a .NET assembly that will be registered for COM so that it can be referenced by Microsoft Excel VBA. The assembly references a third-party .NET assembly (that contains some useful classes) that is not in the GAC, however, I have a problem with the deployment of my assembly since the path to the third-part...

WriteByte, how to use it.

How do I use WriteByte? The below code will not work, coming up with both a CS1502 error, and a CS1502 error at the "stream.WriteByte(totalSeasons);" line. It's frustrating because I am incredibly close to finishing this program. Essentially, my problem is that I need to write binary data to a file on the click of a button. I can just w...

How to convert int or bool to checkState

I need to convert int and or bool to checkState int ValueCheck; private void gsCheck1_CheckedChanged(object sender, EventArgs e) { CheckBox box = sender as CheckBox; box.CheckState = ValueCheck; // doesn't work this.gsCheck2.CheckState = ValueCheck; // should be 1 or 0 ? } As you can see I want to change (this.gsChec...

I am trying to figure out a way to streamline importing data from an access database into a .Net application

I'm writing a fairly light-weight .Net application that queries an Access database and generates a Crystal Report based on the result-set. The Dataset fill method is a little slow, but manageable. The issue is when I load the crystal report. If the dataset being passed to Crystal is sizeable, at all, it takes forever to load, and the u...

What's the easiest way to get an OutOfMemoryException in C#?

Just curious as to how I can get this error the easiest way. Once I was trying to create a file navigator and I was creating Image thumbnails; that turned out awful. ...

Using the OpenFileDialog control in a C# application.

Hi there, I'm sure I've asked this question before but searching does nothing and I completely forgot how to do this. I need a way to have a user choose a picture from their hard drive and load that picture to an Image class using the location. I've done this in the past, but as I said I can't remember how I did it. I know you can app...

Can an Enum only hold numerical values and not string?

I have this Enum: enum ASCIIChars { BLACK = "@", CHARCOAL = "#", DARKGRAY = "8", MEDIUMGRAY = "&", MEDIUM = "o", GRAY = ":", SLATEGRAY = "*", LIGHTGRAY = ".", WHITE = " " }; Here is where I am using it: private ...

Why cannot I select from more than one table in Oracle?

Hi, I'm using Oracle 10g Express Edition 10.2 and I use it from a C# application with Oracle.DataAccess 2.111 assembly. I can select data from one table, but if I try to select data from several tables, the set is empty. select * from Table1 works well, but: select * from Table1, Table2 select * from Table1, Table2 where Table1.Id ...

Multiple Subscriptions from one Observer in Rx

I am trying to refine the filter in my Observer over time, and I was wondering what they best way of doing this is. e.g. myObservable.Where(x=>x.Color=="red").Subscribe(); and then myObservable.Where(x=>x.Color=="blue").Subscribe(); and then merge the two into one stream so that OnNext() is called on Red OR Blue observables. Maybe it...

How can I make ASCII text that will look good on Facebook?

I'm making a .NET application that will take any picture and spit out ASCII text that will appear just like the image. So far, it works well when the font is Lucida Console. Facebook doesn't use this font and thus break the art illusion. Any thoughts, ideas and suggestions on how to tackle this problem? It's pretty a pretty neat idea! ...

Microsoft.Build.Utilities.FileTracker threw an exception error. Happens with different projects

Lately with Visual Studio 2010 Ultimate, C#, in Win7 64bit, I get the error below when I compile any project. The workaround is to add <TrackFileAccess>false</TrackFileAccess> to the project file. If I am not mistaken this would disable incremental builds so I want to stay away from this workaround. Anyone knows what the permanent relia...

How can I use an array-initializer syntax for a custom vector class?

I have a class roughly designed as such: class Vector3 { float X; float Y; float Z; public Vector3(float x, float y, float z) { this.X = x; this.Y = y; this.Z = z; } } I have other classes implementing it as properties, for example: class Entity { Vector3 Position { get; set; } } ...