|
Hi all,
I would like to know isit possible to add a new rule/logic like "If X>Y then.. " into application during "runtime" environment. I mean that i can edit/add the code during "runtime" environment without open the source code in C#.
Any tips (in any programing language- vb,vb.net,c#)or related sources are welcome.
Thanks in advance
regards
lswang
|
|
|
|
|
|
|
|
You can do this. The technique that you are talking about is called a Rules Engine. There's a very good one available for .NET called NxBre.
|
|
|
|
|
Hi Pete O'Hanlon,
Is any example source/tutorial on NxBre. Please redirect me to the right way.
regards
lswang
|
|
|
|
|
|
Hi, i am trying to pass an array of struct in c# but I keep getting Inconsistent accessibility errors. I am including the code below:
________________________________________________________________________________________________________________
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace friendstruct
{
class Program
{
class friendType
{
public string name;
public string age;
}
public static void load_data(friendType[]friends)
{
Console.WriteLine("Hello");
FileStream file = new FileStream("Marilia.txt", FileMode.Open, FileAccess.Read);
StreamReader reader = new StreamReader(file);
load_data();
for (int i = 0; i<3; i++)
{
name = reader.ReadLine();
str_age = reader.ReadLine();
age = Convert.ToInt16(str_age);
friends[i].name = name;
friends[i].age = str_age;
}
reader.Close();
}
public static void Main(string[] args)
{
int age;
string str_age;
string name;
friendType[] friends = new friendType[10];
load the data from the data file
load_data(friends);
//print the data file out
for (int i = 0; i < 3; i++)
Console.WriteLine("{0} {1} ", friends[i].name, friends[i].age);
}
}
}
_________________________________________________________________________________________________________________
|
|
|
|
|
Jerry Graham,
If you change:
class friendType
{
public string name;
public string age;
}
To:
public class friendType
{
public string name;
public string age;
}
I think it should work. Basically, the error is because one class is set to public and the other isnt.
Regards,
Gareth.
|
|
|
|
|
Hi,
That worked. thanks a lot. I have no syntax errors, however the problem crashes in the load_data() function when I attempt to insert a value into the array.
friends[i].name = name;
causes the following error:
Object reference not set to an instance of an object
|
|
|
|
|
Jerry Graham,
In your code, you only create an array, you dont create any instances. So, you need to do:
friendType myFriend = new friendType();
myFriend.name = "bob";
friends[i] = myFriend;
On a side note, i'd personnly change your array to a generic list. eg:
List-friendType- friendArray = new List-friendType-;
(Change the "-" to "<" and ">", it wouldnt let me add them, guess CP doesnt allow for naughty HTML to be inserted)
This is because as you create the array, you set its size to be 10, now if you always populate that array with 10 friends, then its fine. But what if you want 11, your array doesn't handle that or if you only have 9 friends, then you have a null item. Just a tip.
Also, its a good idea to follow the standard naming convention.
http://msdn2.microsoft.com/en-us/library/ms229045.aspx[^]
Regards,
Gareth.
modified on Tuesday, March 25, 2008 3:17 PM
|
|
|
|
|
I guess what is a bit puzzling to me is that this same code works if I use a single main function. it is only after I extract the reading of the data file into the load_data() function that these problems occur.
|
|
|
|
|
Your suggestion worked. However could you tell me why this works?
--------------------------------------------------------------------------------------------------------------------using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace friendstruct
{
class Program
{
struct friendType
{
public string name;
public string age;
}
public static void Main(string[] args)
{
int age;
string str_age;
string name;
friendType[] friends = new friendType[10];
//load the data from the data file
FileStream file = new FileStream("Marilia.txt", FileMode.Open, FileAccess.Read);
StreamReader reader = new StreamReader(file);
for (int i = 0; i<3; i++)
{
name = reader.ReadLine();
str_age = reader.ReadLine();
age = Convert.ToInt16(str_age);
friends[i].name = name;
friends[i].age = str_age;
}
reader.Close();
//print the data file out
for (int i = 0; i < 3; i++)
Console.WriteLine("{0} {1} ", friends[i].name, friends[i].age);
}
}
}
-------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
When you create an array of structures, the array contains the instances of the structure.
When you create an array of objects, the array contains references to the objects. All references are null when you create the array, so you have to create the instances and assign the references to the array items.
Structures are tricky to use, especially if they are mutable, as your structure is. Unless you have a really good reason to use a structure, just keep to using classes.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thank you! I guess C# struct/class relationship is different from c++ class/struct.
|
|
|
|
|
Jerry Graham wrote: I guess C# struct/class relationship is different from c++ class/struct.
It certainly is. In C++ the struct is just a definition, and how you use it decides if it becomes a value type or a reference type. In C#, a struct is always a value type and a class is always a reference type.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hello,
I have a web app where I am able to authenticate logins against Active Directory locally. However when I deploy the application to the production server and try to authenticate it says "The server is not operational." Can anyone please advise what I'm doing wrong?...Thanks in advance.
|
|
|
|
|
Hi All
Have spent all day trying to extract data from any one of the ready made containers that are easily bound to a SQL source without any success, this has been extremely frustrating.
I would really appreciate some help and a very simple step by step explanation of how to resolve this issue.
This is what I am trying to achieve - Steps 3 & 4 are not a problem.
Step1, Get 1 value from a container (bs_bond_price)
Step2, Stuff the value into a local variable
Step3, Get 1 value from a user textbox external to the container
Step4, Multiply value 1 by value 2 and show in a label
Example
----------------------------------------------------------------------------------
<asp:DataList ID="DataList1" runat="server" DataKeyField="bs_bond_price" DataSourceID="test"
Style="z-index: 108; left: 16px; position: absolute; top: 394px" OnSelectedIndexChanged="DataList1_SelectedIndexChanged">
<ItemTemplate>
bs_bond_price:
<asp:Label ID="bs_bond_priceLabel" runat="server" Text='<%# Eval("bs_bond_price") %>'></asp:Label><br />
<br />
</ItemTemplate>
</asp:DataList>
------------------------------------------------------------------------------------
I would really appreciate some help
many thanks in advance
Regards
DD
modified on Tuesday, March 25, 2008 1:47 PM
|
|
|
|
|
I'd recommend asking this in the ASP.NET forum.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks for coming back
Although:
1, I need advice on how to get data values from C# objects (hence why I asked here)
2, I have not got a clue where you got that function name from. There are no Functions/Methods in the ASP example I gave (the reason for giving the ASP.NET example by the way is all C# objects are noted here)
So I resume my request for somebody to help me please
As I mentioned previously I really want to get a data value from a container and use it externally of the container.
Regards
DD
|
|
|
|
|
1 - you're using ASP.NET, and unless you're wanting to do what you're talking about on the server, you want to do it with javascript. It's not clear from your post, but, either way, it's an ASP.NET question.
2 - what function ? You're not thinking my sig block is part of my answer, are you ?
If you can explain yourself a little more clearly, do you want to set up a textbox so that it has a specific value for the lifetime of the page, or do you want the value to change as they user interacts with the page ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
dropped you a mail with some more details on
and yes I was being a complete plank and got your confused with your signblock - been a log day and frustrating day so far.
|
|
|
|
|
OK - I am not at home right now, I'll look at it when I get home. But, it might make more sense in the meantime to post the details here, someone else may well be able to jump in and help
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi Christian
Thanks for the reply earlier.
I have managed to fathom out the code which was
x = gridview1.Rows[0].Cells[0].Text;
I had seen something like this earlier when I had been scanning the web, however I thought I would do something simple and test it on a new webpage and sure enough got it working
cheers
DD
|
|
|
|
|
Hi there,
I am looking for a way to retrieve all the Requests that a browser makes after we invoke the WebRequest.Create("http://www.cnn.com"). Within a website, once we invoke the URL, there are many requests has been made from the client to the server, for images, java scripts, css, flash files etc.
I do want to get all those Request object to do some programming.
Any help plz.
Thanks
|
|
|
|