|
Hi Willem,
It looks like an overloaded cast operator. You'd probably want to consider using a 'Single' data type first of all in C#, but when it comes to the code using "(float)MyClass" on your particular class, you'd probably want to replace that with a method call or property that returns the single-point floating result.
Regards,
Joe
|
|
|
|
|
MultiThread wrote:
but when it comes to the code using "(float)MyClass" on your particular class, you'd probably want to replace that with a method call or property that returns the single-point floating result.
Why wouldn't he just keep it as an overloaded cast operator?
When I can talk about 64 bit processors and attract girls with my computer not my car, I'll come out of the closet. Until that time...I'm like "What's the ENTER key?"
-Hockey on being a geek
|
|
|
|
|
Hi David,
He probably could, but that would be due to my ignorance. I did some research and found that the cast operator in C# can't be overloaded, but that C# did allow the use of "explicit" and "implicit" as keywords to allow for that sort of behavior.
Regards,
Joe
|
|
|
|
|
I found the solution
<br />
public static explicit operator float(Fuzzy f1)<br />
{<br />
return f1.fuzzNum;<br />
}<br />
You can then do this:
<br />
float x;<br />
Fuzzy y = new Fuzzy(56.34);<br />
<br />
x = (float)y;
Greetings....
|
|
|
|
|
Cool...glad we could help. Although, you may want to use operator overloading sparingly. Only use it when it makes sense to have an object cast to another object...etc.
When I can talk about 64 bit processors and attract girls with my computer not my car, I'll come out of the closet. Until that time...I'm like "What's the ENTER key?"
-Hockey on being a geek
|
|
|
|
|
I am trying to create a Windows Installer package, can anyone lend some advice on best route if my software needs to connect and deploy some stored procedures?
Thanks in advance
Terance Emory
|
|
|
|
|
Hi Terance,
If your code needs to deploy items which don't already have .NET framework code to do so (i.e. message queues, etc.), you can add an installation component to your application which has callbacks that can act in the context of installing and uninstalling your application.
If you use "Add new item..." to your project, you should find an installer class. This derived class has overrides you can use during the installation process to do work during the install, rollback, commit and uninstall portions of installation.
MSDN online provides a walkthrough on how to create a database, the same example can be adapted to add your stored procedure to the database during installation.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/html/vxwlkWalkthroughUsingCustomActionToCreateDatabaseDuringInstallation.asp
Regards,
Joe
|
|
|
|
|
Thanks Joe,
This looks like exactly what I needed many thanks
|
|
|
|
|
Hi guys,
I would like to hear you opinion about writing the code for database access in general. I have like 15 books that discuss database access, have read numerous articles, but I am still not sure of the best practices in this area. There are many solution to this and they all work, different authors offer different approaches, but it is just too time consuming.
I make client applications to access data from SQL server, and as I said I am writing too much code for that. I mean it works, but I should be able to code in shorter period of time. Some common approaches, and my opinion:
1. Use of MS application blocks: this is not such a big help, if I call the stored procedures in one line of code, or 5, it is all same to me, cause I auto-generate it anyways.
2. Use of different data access layers: they all are too complicated, and it only adds to the complicity of my code. I do not need such approach so that I can be flexible to easily switch my code from accessing SQL server to accessing Oracle, or anything like that, cause I will never be doing that.
3. Use of binding context: this is the biggest crap I have seen in .Net. It is not flexible at all, have to basically make binding context for each different control on the form, have no control over the process, very hard to keep grid and controls data in sync... Will never use it.
I usually make a class for each window, cause I always represent data from multiple tables, there are usually grid control, some combo boxes and number of other controls, then I handle moving through data sets and take care of inserting, updating or deleting data in data set by using appropriate methods in that class. Of course, I do it in a locally accessible data set, then I update a database, keeping the local data set view updated. This is all fine, but it takes TOO MUCH TIME to code like this for every window I need.
I just wanted to hear you opinion about this, I mean there has to be a quicker way to this.
Thanks in advance.
|
|
|
|
|
I used a 3 layer method. I have the database, a special class I designed to do the Read,Insert,Update,Remove things for me. And the user part.
This works fine for me. Ok, I have 40.000 lines of code at the moment. But the application is fast, has a lot of features and zero errors. (At least the users say so )
But you can also use plain and simple: the data adapters and datasets from the .NET Framework. Less code to write, but it uses up more memory then probably needed.
Greetings....
|
|
|
|
|
Does anybody know anything about C# applets?
What restrictions implies, if any?
Sergiu.
|
|
|
|
|
??
I didn't know there were C# applets?
Greetings....
|
|
|
|
|
I don't think there are C# applets in the same way there are Java applets
However you should be able to issue C# applications as ActiveX controls if the client system has the .NET Runtime installed. Simply register the application for com interopt and host it on a web page.
I've never tried this or heard of it being done but I've also never looked into the issue.
Jared
jparsons@jparsons.org
www.prism.gatech.edu/~gte477n
|
|
|
|
|
You dont need to make an activeX, just make a control library .dll file with
a class extending the Control class.
It is strange that microsoft didnt tell anything about it. You can search
for yourself in msdn.
Sergiu.
|
|
|
|
|
In VB.Net this late binding works fine
Dim Version As Integer
Dim Revision As Integer
Dim Wnum As Integer
Dim o As System.Array = System.Array.CreateInstance(GetType(Single), 1)
Dim h As System.Array = System.Array.CreateInstance(GetType(Single), 1)
Dim l As System.Array = System.Array.CreateInstance(GetType(Single), 1)
Dim c As System.Array = System.Array.CreateInstance(GetType(Single), 1)
Dim Vol As System.Array = System.Array.CreateInstance(GetType(Int32), 1)
Dim Dates As System.Array = System.Array.CreateInstance(GetType(Int32), 1)
t = CreateObject("TC2000Dev.cTC2000")
Wnum = 1000
Revision = t.GetRevision
Label1.Text() = Revision
t.GetPrices(Wnum, o, h, l, c, Vol, Dates, 100)
Label2.Text() = c(1)
When it is converted to C# late binding, the GetRevision method works but the GetPrices does not
GetRevision only is suppose to return an Int32, but GetPrices is supposed to return multiple System.Arrays
int WNum = 1000;
System.Array _open = new System.Single[1];
System.Array _high = new System.Single[1];
System.Array _low = new System.Single[1];
System.Array _close = new System.Single[1];
System.Array _vol = new System.Int32[1];
System.Array _date = new System.Int32[1];
object[] d = {WNum, _open, _high, _low, _close, _vol, _date, day};
Type myType = Type.GetTypeFromProgID("TC2000Dev.cTC2000");
object myObject = Activator.CreateInstance(myType);
//Works
Int32 Revision = (Int32) myType.InvokeMember("GetRevision",
BindingFlags.Default | BindingFlags.InvokeMethod,
null,
myObject,
new object[]{});
label1.Text = Revision.ToString();
//Does not work
d = (object[]) myType.InvokeMember("GetPrices",
BindingFlags.Default | BindingFlags.InvokeMethod,
null,
myObject,
new object[]{WNum, _open, _high, _low, _close, _vol, _date, 100});
How does the InvokeMember need to change to allow the GetPrices to work?
WNum and 100 are the input params, and _open, _high, _low, _close, _vol, _date are system arrays that are returned
Thanks
|
|
|
|
|
I am allowing image editing in my application. I can modify the gamma setting, but am having a difficult time modifying the brightness and contrast of the image.
I have checked the imaging.members area and could not find anything the remotely sounds like what i need.
Any suggesstions
THanks
James
|
|
|
|
|
Using C# and .NET, I am able to write most data to a database.
I do this by creating a new row in the dataset, setting the column
values, and then using the data adapter's Update method on the dataset with the new row.
This works fine until I try to do an update with an array object in one of the rows.
When I designed this particular table, the row I want to accept the array is
of SQL_Variant type. When the new row is created, it is a System.Object.
The row accepts the System.Array I put in there.
But the Update() throws an exception of unspecified error.
Any idea how I can accomplish getting my fixed array into the
database?
Thanks!
|
|
|
|
|
It is an array of what?
It really sounds like you want to create a new table and put a row for each element of the array.
--Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
|
|
|
|
|
Ok, I'll try to make this as short as possible. I have wrote a C# app that creates static HTML pages. One of the pieces for each page is obviously the keyword meta tags. To thicken the plot, this same program generates the same pages for different sites. But different keywords for each site. What I'm trying to accomplish is to have an external XML file that basically "defines" what the keywords are for each site.
My question is this, what if I want to change say the Persons name for each of my pages, but using the same keywords. Example: Visit Bob Smith's Home Page
My Application is going to have the name Bob Smith defined, so basically when I import my XML it needs to have a place for a variable. So the XML file should read Example "Visit" + theName + " Home Page". So when it comes into my app + theName + get's defined as Bob Smith's.
Obviously it doesn't work this way and I need it to. Any ideas. Hope I haven't confused the hell out of everyone
-Brent
|
|
|
|
|
Hi Brent,
It sounds almost like you want to add meta tags to your meta files. Actually, it's not uncommon to have a file template that is pre-processed in order to feed it to the appropriate consumer.
A classic example is the pre-processor .h files used by C/C++ compilers. However, in your case, you want to take existing XML files and use them directly with text replacement. Probably not very easy to do with the XML parser directly, but perhaps you can consider this:
Create your own "XML template" with a different file extension; allow a certain delimiter to define 'tags' in the XML file which don't clash with the XML syntax. Create a component which can take a collection of name-value pairs, and the name of your file to read the file, parse out the 'tags', and replace the name of the tag with the value in the collection (with the tag name as the key). The resulting text replacement is then the new "dynamic XML" that you can then feed to your application.
There are probably other ways of doing such with XSL, but that's one realm I've not yet trodden.
Regards,
Joe
|
|
|
|
|
Hi Joe,
Yea, that's exactly what I ended up doing. I defined variables in my XML file with @FirstName@ @LastName@ etc. and then just look for those values once I import the XML....works pretty damn nicely. Like you said, probably a better way, but I'm only dealing with about 6 variables at any one given time so it works
Thanks for the response though!!
-Brent
|
|
|
|
|
Hi there,
No problem, actually, I've used that approach in the past on other project. It does work nicely and the best thing about it is that it's configurable after you've written the code that uses it. (You just have to make sure you don't break what you feed the code!)
It's a good way of branding Web sites, nice to see someone out there thinking that way.
Regards,
Joe
|
|
|
|
|
I am somewhat new to C# and I need to create an app.config file for my application. Does VS.NET automatically create this file and if so, where can I find it? If it doesn't, how would I create the app.config file to use with my program?
Thanks!
|
|
|
|
|
VS.NET should create one for you. If there isn't one you can add right-click on your project in the Solution Explorer and select "Add New Item..." from the menu. In the list of templates you will find (if you scroll to the end) an "Application Configuration File" entry. Accept the name app.config and let it add it to your project.
Remember, and this can be the confusing bit, that your app.config file will be copied to the output directory when you build the project. The copy will be called project_name.exe.config
I hope this helps,
Colin.
--Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
|
|
|
|
|
Hello all
I have solved the problem that I am looking for an answer on, the problem is that my solution isnt very elegant (IMHO) and I was wondering if there was a better way of achieving the effect I am after.
I have a simple XML file in the following format
<?xml version="1.0" encoding="utf-8" ?>
<report_layout xmlns="http://tempuri.org/layout_schema.xsd">
<field>
<type>label</type>
<value>Title Text</value>
<posX>5</posX>
<posY>5</posY>
<width>200</width>
<height>10</height>
</field>
<field>
<type>label</type>
<value>A Value :</value>
<posX>5</posX>
<posY>20</posY>
<width>200</width>
<height>10</height>
</field>
<field>
<type>label</type>
<value>Text Value</value>
<posX>210</posX>
<posY>20</posY>
<width>200</width>
<height>10</height>
</field>
</report_layout>
I have a piece of code that parses through this and reads out the values of the elements within <field>, but I am having to use lots of xml.Read() commands to move through the file, is there a way to go to an element gets its value and move to the next?
while(xtr.Read())
{
if(xtr.NodeType == XmlNodeType.Element)
{
if (xtr.Name == "type")
{
FormComponent fc = new FormComponent();
xtr.Read();
fc.type = xtr.Value;
xtr.Read();xtr.Read();xtr.Read();
fc.value = xtr.Value;
xtr.Read();xtr.Read();xtr.Read();
fc.posX = Convert.ToInt32(xtr.Value);
xtr.Read();xtr.Read();xtr.Read();
fc.posY = Convert.ToInt32(xtr.Value);
xtr.Read();xtr.Read();xtr.Read();
fc.width = Convert.ToInt32(xtr.Value);
xtr.Read();xtr.Read();xtr.Read();
fc.height = Convert.ToInt32(xtr.Value);
fc.PrintComponent(lboxXMLValues);
this.Controls.Add((Control)fc.CreateComponent());
}
}
}
post.mode = signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|