|
ASPnoob wrote: I understand that usually when you need to pass data from a method to another
method the the method doing the sending has to be some other type than void
Uhhh, that description is vague at best. The method calling another method can be anynthing. The method RETURNING a value must not be void. But, that doesn't mean a void method cannot return data/values. It can still return data via Ref parameters.
Can you do this with PageLoad?? No. You can't change that method. You can only do this with code/method headers you have control over.
Like Pete said, what you're wanting to do is easily done using properties and fields set by the code in PageLoad.
|
|
|
|
|
Hi All, I understand that usually when you need to pass data from a method to another method the the method doing the sending has to be some other type than void. Having said that, is there anyway I can get data from the PageLoad method which is of type void? Thanks in advance.
|
|
|
|
|
I have two questions to ask about passing arguements to a C# 20008/2010 console application:
1. In an existing C# 2008 console application that I have made changes to, I have asked the network administrator what values are passed to the application. He told me none. However after I have debugged the application, I find it hard to find beleive that no arguments are passed to the application. Thus can you tell me where to look to see what variables are passed to the application that is setup in a windows scheduler for windows 7?
2. I have just written a C# 2010 console application that I pass values to. I need to setup the windows scheduler to run the job once a day and I need to pass the application some input argumements.
Thus can you answer my two question? Pointing to a url link would be helpful also!
|
|
|
|
|
Check your
Main(string[] args) method.
args will contain the arguments that were passed to your application.
This[^] will show you how to use the task scheduler
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
hi guys , im wondering if there are any soluation for my qustion .
i have two 2D array here , first and second array are defined like this
int [,] MyfirstArray = {{0,3,2},{4,1,5},{6,7,8}};
int [,] MySecondArray = new int[3,3];
MySecondArray = MyfirstArray;
what do i want to do its just to exchange the value of 2 block of the second array . Take alook
int NewValue = 0;
int Old Value = 0;
NewValue = MySecondArray[1,0];
OldValue = MySecondArray[0,0];
MySecondArray[0,0] = NewValue;
MySecondArray[1,0] = OldValue;
and i know that array is ref type but i dont know why after im doing this , both of the arrays value are changed .
the result is like this . MyfirstArray = {{4,3,2},{0,1,5},{6,7,8}};
MySecondArray = {{4,3,2},{0,1,5},{6,7,8}};
but i dont want this effect on the first array . and maybe you wondering why im using 2 array , just guess i need the first array and i cant remove or not use it . ty for any help .
|
|
|
|
|
You have to make a copy of your MyFirstArray in order to do what you want. You cannot just assign MySecondArray to it becuase now you have two variables (arrays) pointing to the same set of data, your integers.
See Array.Copy[^].
|
|
|
|
|
Im sorry for my stupid qustion but how to make that
mmm , can you show me an example to clear me up .
|
|
|
|
|
Array.Copy(MyfirstArray, MySecondArray, MyfirstArray.Length);
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
Seriously? I gave you a link to the very documentation you need to read and you couldn't put that much effort into it an try stuff out??
I'm not going to write the one line of code for you.
|
|
|
|
|
I have classes in an assembly that I have been able to load using Assembly.LoadFrom() method. I now need to call a method in a class from the loaded assembly but I don't know how to do that.
I tried the following:
Assembly asm = Assembly.LoadFrom("LibTry.dll");
if (asm != null)
{
object obj = asm.CreateInstance("LibTry.Try");
Type[] types = asm.GetExportedTypes();
}
I'm able to create an instance of a class in the assembly and the return value in
'obj' is valid and not null.
By running the debugger, I set a breakpoint at the line
Type[] types = asm.GetExportedTypes();
I hovered the mouse over the return values and I saw the name of the class in the
'obj' and the exported types in 'types'.
The problem now is to make function calls from the class. Is there any way I can create an instance of the exported types using the name of the class rather than 'object' or call and use the public members in the class? Please help and thanks in advance.
modified 22-Sep-12 8:34am.
|
|
|
|
|
Use the GetMethod member from the Type , similar to the code below;
namespace bla
{
public class X
{
public void Test(string what)
{
Console.WriteLine(what);
}
}
class Program
{
static void Main(string[] args)
{
Assembly asm = Assembly.GetExecutingAssembly();
if (asm != null)
{
object obj = asm.CreateInstance("bla.X");
Type xType = obj.GetType();
MethodInfo mi = xType.GetMethod("Test");
mi.Invoke(obj, new object[] { "Hello World" });
}
Console.ReadKey();
}
}
}
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks Eddy! It's working now. I hope it works for fields as well. I will try that soon.
|
|
|
|
|
You're welcome, and it does, using the <a href="http://msdn.microsoft.com/en-us/library/53seyfee.aspx">GetField</a>[<a href="http://msdn.microsoft.com/en-us/library/53seyfee.aspx" target="_blank" title="New Window">^</a>] method, also found on the objects' type. It'll return a <a href="http://msdn.microsoft.com/en-us/library/system.reflection.fieldinfo.aspx">FieldInfo</a>[<a href="http://msdn.microsoft.com/en-us/library/system.reflection.fieldinfo.aspx" target="_blank" title="New Window">^</a>] variable over which you can access it's content, or fetch it's attributes.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Dan_K wrote: The problem now is to make function calls from the class
You could use an interface.
|
|
|
|
|
You can use the reflection API to call methods, properties and fields of any class, including those that you've loaded from an assembly at runtime. This is what Eddy's pointed you at.
However, reflection is slow, and also pretty cumbersome to write code for. If you know what methods you want to call, then that means you can define an interface, and if you're writing the assembly you're trying to load from (or people are writing them to an API you specify), you can make sure the class you try to load implements it. Put that interface in a library that both the main application and the external library can refer to (this can be actually in the application assembly in some cases), and make sure that the classes you want to interact with in the external assembly implement it. You can then cast the result of Activator.CreateInstance to the interface and call methods on the instance directly.
There are several examples of plugin architectures (because that's what your close to) available on CP. Here's a simple example modified from a previous version of my LobbyClient (the current one loads plugins into a separate AppDomain which you probably aren't looking for):
public static IGameType LoadContent(String filename){
Assembly a = Assembly.LoadFrom(filename);
if(a == null) throw new GameLoadException("Assembly "+filename+" not found or not valid");
foreach(Module mod in a.GetLoadedModules()){
foreach(Type ty in mod.GetTypes()){
foreach(Type intf in ty.GetInterfaces()){
if(intf == typeof(IGameType)){
return (IGameType)System.Activator.CreateInstance(ty);
}
}
}
}
}
IGameType is specified somewhere that plugin classes can see it when you're writing plugins.
|
|
|
|
|
Dear All
I have created an application with database ms-access where i have defined all the field as memo data type to store hindi text . All data successfully stored and comes to crystal report in hindi text but when i look this data in datbase (ms -access) text displays in english but this is not issue.
Problem is when i give the print command all text prints in english text instead of hindi and also it is just same as displaying in database.
plz tell me the problem whether it is coming due to printer(HP Laser JEt J1008) or from the application.
|
|
|
|
|
It's not the printer; it does not care what language you're printing.
It's probably the database - with the text not saved as unicode, but in a specific format. I suggest you try a forum that's dedicated to Microsoft Access.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Try another printer with another type
I faced the same problem with Fast-report.net
It's worked with all kind of printer, but not these two HP 1010 , HP 1008
Due .NET ,,
|
|
|
|
|
I am working in a C# 2010 application where I have written the following lines of linq to sql code:
int TotCount = 0;
string[] PkgIDs = rptData.Transaction.Where(c =>c.Package_ID.StartsWith("rva") &&
c.Received_Date != null ).Select(c => c.Package_ID).ToArray();
foreach (string PkgID in PkgIDs)
{
var eCnt = rptData.Details.Where(c =>c.Package_ID == PkgID).Select(c =>c.TotalTrans);
TotCount = Convert.ToInt32(eCnt);
}
My problem line of code is: var eCnt = rptData.Details.Where(c =>c.Package_ID == PkgID).Select(c =>c.TotalTrans);
I want to be able to obtain the value contained in the c.TotalTrans field and place the value in the eCnt field.
When I am stepping through the code and go to the line right after the line I listed above, I only see the sql equivalent value. I want to see the value for c.TotalTrans in the eCnt field.
I know what I need now is to actually make the linq to sql statement actually execute. That would be similar to the 'ToArray()'
statement listed above. However, I do not know what to change in the statement to actually obtain the value.
Thus can you tell me what else I need to add to this statement so that I get my desired
|
|
|
|
|
Remember that the .Select(c =>c.TotalTrans) returns IQueryable<...> . You'll need to get the value from there. You probably want to use .FirstOrDefault() .
|
|
|
|
|
I'm a little confused about the TFS team project hierarchy.
From what I have read just about everything for your group (projects/applications/etc) should be contained in one TFS team project? Can anyone concur with that statement? I, for some reason, thought that a single team project in TFS was mapped to one VS project/solution, but I think I misunderstood the hierarchy. I know it can but it seems like complications will arrise when you have to work on two team projects in the same scrum iteration. The work items don't translate over from one project to another.
-- modified 21-Sep-12 17:53pm.
|
|
|
|
|
I don't think putting all your projects/solutions in the same Team Project would be very wise, mostly because, depending on the size and depth of them, it could become unmanageable pretty soon.
In the end I think it all depends on how your team likes to organize (especially, if you are gonna use TFS as more than a glorified VSS) but I prefer to have every solution in its own Team Project
|
|
|
|
|
If you keep each VS solution in one team project in TFS how do you handle situations where you have to work on two solutions with the same scrum iteration? Because you have different backlogs for each solution you would need to have two different sprints and that doesn't seem very efficient. right? You can't tie in work items from different team projects together and have them run under the same sprint/iteration. According to the TFS 2010 book by Wrox, one soltution they suggest is to put all applications into a single team project and seperate them by "areas" and "iteration". Isn't this a better solution then creating one team project for each and every solution given TFS limits team projects to something like 250 before performance degradation.
-- modified 21-Sep-12 18:06pm.
|
|
|
|
|
can we develop optical character recognition (OCR)using MonoDroid(convert C# code into Android).
|
|
|
|
|
I don't think your question is very clear, are you asking for people to just give you the code? If so, then the answer is NO, otherwise, please elaborate
|
|
|
|