|
That's because you are passing the thing as an object, instead of whatever type it really is. Your method signature should probably be something like this:
public bool Add( Agent agent )
{
string agentName = agent.agentName;
...
}
From what you've shown, there is no need to have the ref keyword in there.
Also, you don't need Hungarian notation with C#.
Matt Gerrans
|
|
|
|
|
thanks Matt
but i can not declare Agent type in this function, because it is defined in data layer that do not have reference of business layer. therefore, i have to declare object type.
|
|
|
|
|
If you can't reference the class, then you can't do anything with it (unless you use reflection).
If you don't want the data layer to know the business class, then make an interface with the properties you want to expose, and make the business class implement it, and reference the interface in the data layer.
---
b { font-weight: normal; }
|
|
|
|
|
Guffa's suggestion is probably the way you should go.
Another quick-and-dirty option, if Add() only needs a few things, is to use parameters. For example:
Add( string agentName, int agentId );
Another one that's even more of a hack is to pass an attribute/value Hashtable.
Matt Gerrans
|
|
|
|
|
i am just starting out with using microsoft visual c# and have made a browser window to use as a client for a web based game everything works as expected besides one thing....
when you click the play button for the game... it opens a new window... i am looking for a simple way to over ride this and make it open in the program window.... if i right click the link and click open link it opens the way i want it to....
but i think the developers have embedded the code into the page causing it to open in a new window....
if anyone would be willing to help me i have msn at voxcustoms@hotmail.com and i can send you the project... i would appreciate any and all help i could get.... i am starting to get discouraged with this... i have looked at about 100 different pages and havent been able to find it on the web since i have no idea what most of it is talking about....
thank you in advance....
Nathan
|
|
|
|
|
Hello There,
I am working with c# & I have used two textbox server control.
1> Registration Date
2> Expiry Date
First of all, user enters value for the first textbox namely Registration Date and then the expiry date should be auto calculated by adding 30 days into currently entered registration date when he user leaves the first textbox.
That means there are two textboxes - user enters the value for first textbox and the second textbox should be auto calcuated on lost focus event of first textbox.
So pls let me know..... Waiting for your answer....
Thanks,
Paresh
|
|
|
|
|
textbox2.Text = DateTime.Parse(textbox1.Text).AddDays(30).ToString();
xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
|
|
|
|
|
Ok here i am again the CP having hit my head on the wall as much as possible for this 2 days...
It was more that 1 year i didn't do anything in C#...
now after a lot of ice on my head i got it, my CDAWG
(Word here is a byte pointer)
the class is finally working, it takes imput strings, convert them to bytes and fill the tree... it's very unsafe.... i use ** and * with a clas for the heap memory allocation taken from the examples of the msdn very short code and always worked fine.
What can i do now???
that's what i did, i took the wikipedia dump file with all their articles names, one per line.1471780 witout the jap ones (but the class would work ok anyway, even with jap thanks to byte representation)
it's 25Mb of a text that have an article name per line...
cool i'm loading it into my class.. and it does the insertion quite faster then what i thought.
the test on word are just WOW.. i mean... almost "instant"
but now the stuff is... why does it take 130Mb of Memory? shoudn't the tree be
"Compact"?
What i wanted to know is if any of you may tell me if this result is "normal"
should a 25Mb file made with one word per line take up to 130Mb when loaded into an normal CDAWG???
<- true inside to understand outside ->
-- modified at 0:28 Thursday 20th October, 2005
|
|
|
|
|
1:5 is not a bad ratio for a datastructure like a graph.
xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
|
|
|
|
|
hi..
Anyone there able to help me?? I'm currently doing a project on C# web application.. But somehow, i was totally new to this software. My problem is that i have design a user log in interface.. BUT i need to check whether my password and username is it key in correctly.. If it is right, it'll go to the next page and if it is key in wrongly it will prompt out a error message. I have design out the web page and now i'n unsure about the code which i need to put in.. What do i need to type in my Login button so i can check whether my password and username is type correctly?? I need to check through SQL database.. It goes something like that:
private void BLogin_Click(object sender, System.EventArgs e)
{
}
thankz =)
Cheese_kid =p
|
|
|
|
|
using System.Data.SqlClient;
....
private void BLogin_Click(object sender, System.EventArgs e)
{
SqlConnection conn=new SqlConnection(YourConnectionString);
string strSql="select count(*) from UserTable where UserName=@UserName and PassWord=@PassWord";
SqlCommand command=new SqlCommand(strSql,conn);
command.Parameters.Add("@UserName", SqlDbType.NVarChar,50);
command.Parameters["@UserName"].Value=UserName;
command.Parameters.Add("@PassWord", SqlDbType.NVarChar,50);
command.Parameters["@PassWord"].Value=PassWord;
if(int.Parse(command.ExecuteScalar().ToString())>=1)
{
//exist,successful;
}
else
{
//not exist,failed!
}
}
|
|
|
|
|
Hi...
there's some problems going on that i need your help again:
SqlConnection conn=new SqlConnection(YourConnectionString);
(YourConnectionString) means the SQL database file is it?? and the command.Parameter is it used to pass in the value we key in??
Cheese_kid =p
|
|
|
|
|
yep..
have you ever used c# or other language to connect database?
YourConnectionString means connectionstring,including name,password of the
database.
i think you may look up msdn to get started
|
|
|
|
|
I'm not absolutely sure of their value to you, but you might want to look at this. [^]
Regards,
Jerry
"Art doesn't want to be familiar. It wants to astonish us. Or, in some cases, to enrage us. It wants to move us. To touch us. Not accommodate us, make us comfortable." -- Jamake Highwater
Toasty0.com
My Grandkids
-- modified at 0:29 Thursday 20th October, 2005
|
|
|
|
|
Hihi.. I have some error going on.. The error message is:
The type or namespace name 'command'&'sqlcommand' could not be found (are you missing a using directive or an assembly reference?)
Cheers!
|
|
|
|
|
Hi,
Just wondering if anyone here can help me with a problem that I'm experiencing:
Basicly I would like to access a parent class from a DLL file.
Here is an example of what I'm talking about:
This is a chef program, used for automated cooking, it has a class libary with main functions, and class libaries for each kind DLL files. So for main cooking functions I have ChefProgram.Functions.dll, for baking a cake I have ChefProgram.Cake.dll, etc.
ChefProgram.Cake.dll
<br />
namespace ChefProgram <br />
{<br />
class Cake : System.Web.UI.Page <br />
{<br />
<br />
public void Bake_A_Cake () <br />
{<br />
<br />
<br />
ChefProgram.Functions _maintasks = new ChefProgram.Functions(); <br />
_maintasks.Bake_In_Oven(item); <br />
<br />
<br />
}<br />
<br />
public bool Item_Is_Cooked () <br />
{<br />
if (Cake.Color = "golden brown") <br />
return true; <br />
else <br />
return false; <br />
}<br />
<br />
}<br />
}<br />
ChefProgram.Functions.dll
<br />
namespace ChefProgram <br />
{<br />
class Functions : System.Web.IU.Page <br />
{<br />
<br />
public void Bake_In_Oven () <br />
{<br />
Put in oven; <br />
bool Item_Cooked = false; <br />
while (!Item_Cooked)<br />
{<br />
Item_Cooked = parent.Item_Is_Cooked(); << - I NEED TO KNOW HOW TO DO THIS!!<br />
} <br />
Take out oven; <br />
}<br />
<br />
} <br />
}<br />
So we start in ShopProgram.Cake.DLL, in the "Bake_A_Cake()" proceedure, when it is time to put it in the oven we refer to the Functions class which has a "Bake_In_Oven" proceedure, because baking in an oven is something that you do for many dishes.
Since different dishes take different amounts of time to cook the ShopProgram.Cake.DLL also has a proceedure called "Item_Is_Cooked" which is designed to test if a cake is cooked, it then passes true or false back to the "Bake_In_Oven" procedure.
I haven't been able to figure out how to access the parent class to call the "Item_Is_Cooked" proceedure, does anybody know how to do this?
Thanks
-- modified at 21:07 Wednesday 19th October, 2005
|
|
|
|
|
See this[^] on this page.
"Praying." Is this only what I can do for him ?
|
|
|
|
|
you can use multi Polymorphism,declare a base class with an abstract function
Item_Is_Cooked(),and also declare some subclass which implements the base's
Item_Is_Cooked(),so it ok
abstract class BaseClass
{
abstract bool Item_Is_Cooked();
}
class SubClass1:BaseClass
{
bool Item_Is_Cooked(){//implements};
}
|
|
|
|
|
Is clipboard class only used for copying strings or can I use it to copy treeview nodes from one treeview to another?
Thank you
|
|
|
|
|
Will they be copied as thier names?
"I am a liar." Is this statement true or false ?
|
|
|
|
|
As a deep copy (with all the children nodes).
|
|
|
|
|
i use this code to crypt the file i load with opendialog, i get a file 1k bigger the original:
FileStream stream = new FileStream(file_open_path, FileMode.Open, FileAccess.Read);
byte[] data = new Byte[stream.Length];
stream.Read(data, 0, (int)stream.Length);
FileStream writer = new FileStream(file_save_path, FileMode.Create, FileAccess.Write);
writer.Write(data, 0, (int)stream.Length);
stream.Close();
DESCryptoServiceProvider cryptic = new DESCryptoServiceProvider();
ASCIIEncoding ascii = new ASCIIEncoding();
cryptic.Key = ascii.GetBytes(key);
cryptic.IV = ascii.GetBytes(key);
CryptoStream crsStream = new CryptoStream(writer, cryptic.CreateEncryptor(), CryptoStreamMode.Write);
crsStream.Close();
writer.Close();
MessageBox.Show("Il Divx è stato criptato con successo!");
textBox1.Text = textBox2.Text = textBox3.Text = "";
openFileDialog1.FileName = saveFileDialog1.FileName = "";
then i use this one to dencrypt, but i don't free the file becouse i get the seme size and yet crypted, where do i wrong?:
FileStream stream = new FileStream(file_open_path, FileMode.Open, FileAccess.ReadWrite);
DESCryptoServiceProvider cryptic = new DESCryptoServiceProvider();
ASCIIEncoding ascii = new ASCIIEncoding();
cryptic.Key = ascii.GetBytes(key);
cryptic.IV = ascii.GetBytes(key);
CryptoStream crsStream = new CryptoStream(stream, cryptic.CreateDecryptor(), CryptoStreamMode.Read);
byte[] data = new Byte[stream.Length];
stream.Read(data, 0, (int)stream.Length);
int val = (int)stream.Length;
crsStream.Close();
stream.Close();
FileStream writer = new FileStream(file_save_path, FileMode.Create, FileAccess.Write);
writer.Write(data, 0, val);
writer.Close();
MessageBox.Show("Il Divx è stato decriptato con successo!");
textBox4.Text = textBox5.Text = textBox6.Text = "";
openFileDialog2.FileName = saveFileDialog2.FileName = "";
|
|
|
|
|
Sasuko wrote: CryptoStream crsStream = new CryptoStream(writer, cryptic.CreateEncryptor(), CryptoStreamMode.Write);
crsStream.Close();
You have to use the CrtptoStream instance to read and write. You cant use the original stream. You make the same mistake (in 2 different ways) in both your read and write sections.
xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
|
|
|
|
|
can you show me the right code?
|
|
|
|
|
Sasuko wrote: can you show me the right code?
Yes, look in MSDN, there are plenty samples on the correct usage of CryptoStream .
xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
|
|
|
|
|