Answer Questions
DrJoness NO error, but I got only part of what I want to get.
No error was complained! The following program is to write a whole year's month,day,weekday in a MSSQL table. But somehow, for many times I have tried, but each time I got only part of what I intend to get: the whole year with 12 monthes, instead, I only got 3 or 4 months' content in the table. Can anybody tell me why calendar.dll using System; using System.Configuration; using System.Data; using System.Data.SqlClient; using database; namespace calendar { public class calendar { private int _nian; //year private int _yue; //month   ...Show All
rgabel Get member value by its name
Hi, I'm quite familiar with Reflection and types, however I'm not able to manage how to get the value from member's name. Like: namespace MyNamespace { public struct MyStruct { public string MyValue; } public static class MyClass { public static MyStruct TheStruct; } } Now, how can I get the MyValue value, if I have a string like "MyNamespace.MyClass.TheStruct.MyValue" Or if it helps, I can have the "MyNamespace.MyClass.TheStruct" and "MyValue" member name seperated. Thanks, Jan Well you're going to have to figure out somehow that "MyNamespace.MyClass" is a class, get its Type and then use Type.GetField and FieldInfo.GetVa ...Show All
Mark Guenault C# Project generation
Hi I'm working on an app that generates C# source code. I've been using the CodeDOM namespace to handle most of the actual generation of the individual source files and its worked out fine. However, now I'm ready to start generating the CSPROJ files that will contain those source files. I realize that these files are simply XML files and I could just create them myself on the fly but before I go down that path I wanted to make sure that there wasn't a similar abstraction for them somewhere in the .NET framework that will generate the proper project files for me. Does anyone know of such an object Thanks! Jeremy Thanks Jasmine! Also, do you know if there is an alternative way to do this without tying into the Visual Studio model. I' ...Show All
fscarpa58 IntPtr Marshal.AllocHGlobal(int) - Passing record from Managed to Unmanaged Code, IntPtr --> HGLOBAL or PVOID?
To all: Issue: Does this managed method allocate memory on the native Windows heap with GlobalAlloc() (or LocalAlloc()) where the the GlobalAlloc flags include GMEM_FIXED (or LMEM_FIXED); in other words, the memory is pinned and the HGLOBAL return value is in fact a dereferenced void pointer to the actual object Assumptions: GlobalAlloc() and LocalAlloc() perform the same under the 32-bit flat memory model. Similarly, GlobalFree() and LocalFree() perform the same under the 32-bit memory model. "IntPtr Marshal.AllocHGlobal(int)" allocates native memory in managed code. IntPtr in managed code corresponds to an HGLOBAL type in native code; in other words, IntPtr is windows handle to the address of the (address) ...Show All
Skill225 how to invoke overriden base class members from an instance of a derived class
Is there a way in C# to obtain the behavior analogous to that shown below in C++ class MyBase { public: virtual void foo() {printf("base class");} }; class MyDerived : public MyBase { public: virtual void foo() {printf("derived class");} }; main() { MyDerived d; d.foo(); // prints "derived class" d.MyBase::foo(); // prints "base class" } In C#, I could use base.foo() within the definition of MyDerived class, but is there any way to invoke MyBase.foo() from an instance of MyDerived OmegaMan & Peter: I don't have a specific need to do this right now, though I've used this construct in the past in C++ when I had a collection of instance ...Show All
myoungbl HELP: Convert PDF to HTML
Hello all Programmers! I want to write a software myself that can Convert PDF file's content to HTML. But I don't know where to start: Is there any valid ActiveX for this Any exist Function that can extract PDF contents and add it to an HTML file Or anything else that a newbie like me don't know So wonderful if I can receive any reply of yours... Thanks a lot! So many things to learn in this world, hihi : - ) you need to use some PDF SDK that maybe available then generate html from it in some way. in .NET there is no direct way since PDF's are not a Microsoft product really but Adobe as well as having no relevance to the .NET Framework itself. I believe there are a couple of open source PDF projects you can ...Show All
Learning VB Diff between internal & protected internal modifiers..
hi, We know that if we declare anything as internal, that will be accessible within the assembly. And any protected members will be accessed by the subclasses within the assembly. But what is the use of declaring a member as protected internal Any one pls, help me in this regard... thanx... A class in a different assembly derived from the class with the pi attribute still has access to it. If it was internal only the derived class in the other assembly couldn't reach it. And, of course, protected only means the derived class in any assembly can reach it. Hi, It is indeed a bit confusing but if you read below you will see the difference: protected Access is limited to the contain ...Show All
Marcel Vroone Case sensitiveness (For Console Application)
My current code: string math; <insert stuff> math = Console.ReadLine(); if (math == "add") { <Insert stuff> } My problem is that it only triggers if you type add, not when you type ADD or whatever, any idea how I would go about this I know it has something to do with ToLower, but I don't know what to do with it. I tried to do math.ToLower(Console.Readline()); and vice versa which of course didn't work :(. Try this: math = Console.ReadLine(); if ((math.ToLower()) == "add") { <Insert stuff> } I hope it works ;-) Well if you're going to compare multiple values like that, an even clearer way would be to use a switch statement: class ="txt4"> string math ...Show All
sugrhigh Web Service Partial Class
I just converted an application that communicates with the database via web services to VS2005. The conversion worked fine but I could not get the application to communicate with the web services. I kept getting a web method error. So, I decided to convert the web services to VS2005 as well. The conversion of the web services went well also. However, when I generate the proxy class through WSDL.exe, and add the proxy class to my application, it will not compile. The proxy class generated by the WSDL.EXE utility for VS2005 creates a Public Partial Class and the compiler doesn't like it. It throws an error for each of the three Public Partial Classes generated by the WSDL.EXE utility that states: Expected class, delegate, enum, interface, or ...Show All
GLutz78 Find FileName With Wildcard
I have a directory full of image files which need to be copied to another directory when the original is updated. So basically I need to do this: System.IO. File .Copy(originalDirectoryAndName, newDirectoryAndName, true ); The only problem is that the original file has some random characters in it's name, and I need to be able to search by wildcard. How can this be best accomplished Thanks, Russ you have a list of items from the database, file names, with wildcharacters you want to see if the file(s) are updated in a physical path location on your computer if they are updated, then copy them/move them/rename if/do whatever Correct. ok ...Show All
Benin Make object that allows access thru [] (indexed property)
Hi, I was wondering if it is possible to make objects that behave like indexable lists. I have an object that wraps a Dictionary object and I would like to make it possible that the caller also uses the direct approach of talking with my class (meaning using square brackets with the key between) So in short I want to know if it is possible to replace: MyDictionary.GetValue(key); By MyDictionary[key] Many thanks to the one that can help me with this. Ben. You can either use some generic collection like List, Dictionary, .., or you can create Collection for your object. For Example: class Person : Object { int _Id; string _Name public Person() {} public int Id { get ...Show All
Martin00 Underline text
I was wondering if there was any way to underline the text of a string... Application: For right now I am outputing a bunch of strings into a message string to display in a message box. Later I will be outputting to a text file. I have searched the MSDN Lib to no avail; if someone could point me in the right direction, that would be great. Can you use HTML code in VC# Thanks Thom Consider using a RichTextBox and saving as an rtf file. It is not possible to make underlined text in a regular plain-text file (.txt). So a regular string cant be made to be underlined Do I have to wait until i save to a file to have it underlined Can I underline the text in a message box pop ...Show All
eric02 How do i call a method from a different form?
Hi, I have 2 forms that are closely linked with each other: form1. a form which lists a bunch of different layers form2. a form which describes the layer (i.e. name, colour, etc) if i change something in form1, i want to call an update function in to update the display in form2, and vice versa. What is the best way to do this from my knowledge, using delegate only works in one direction, correct me if i'm wrong. My idea is to create the update functions within their respective classes and find some way to call that function from the other form. is that possible i have already set it up so that they are sharing a data structure, i just need them to access each other's functions. thanks. ...Show All
jon albinini Writing Xml from listView
I am trying to get each item from a listview and write it to an xml file. For instance lets say i have 2 items in the ListView: http://download.com/download1.zip & http://download.com/download2.zip. below is the code i have but it gives me an error: Unable to cast object of type 'System.Windows.Forms.ListViewItem' to type "System.String'. XmlNode nodeDload = xmlDoc.DocumentElement; XmlElement Dload = xmlDoc.CreateElement("Download"); XmlElement dataDload = xmlDoc.CreateElement(i.ToString()); XmlText textDload = xmlDoc.CreateTextNode(""); nodeDload.AppendChild(Dload); foreach (string item in aUrlView.Items) { Dload.AppendChild(dataDload); ...Show All
HenryM679 Java to C# Conversion...
Hi, I've got hold of an open source 3D game written in Java (using Eclipse) as the game engine and Irrlicht as the graphics engine. I'd like to port the game engine to .NET 2005 (either C# or VB). First... is it possible Second... I tried to find the Java to C# Conversion Assistant 3.0 that should be installed with VS2005 but I can't seem to find it. Thanks, Ivan Definitely possible although you'd probably do better to find a game engine written in C# as it would be more efficient. Language conversions are great and all but they bring the language limitations with them. Conversions are good when you're on a time crunch but I wouldn't base a new architecture on it because you'll want to ...Show All
