|
you mean to say have i given any security?
|
|
|
|
|
I'm using Visual C#.Net 2005
I'm getting an error when I try to access a memeber variable in aother class. It's showing "Object reference not set to an instance of an object."
This is my code :
public class CCommand
{
public Byte[] byArray;
public bool fnCommand()
{
byArray= new Byte[15];
byArray= { 40, 1, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 10 };
}
~CCommand()
{
}
}
I'm accessing byArray in another class like this in a function
public void fnSend()
{
CCommand clsCommand = new CCommand();
Byte nB;
for (int i = 0; i < 15; ++i)
{
clsCommand.byArrData[i] = new Byte();
nB = clsCommand.byArrData[i];
}
}
Its showing error in this line
clsCommand.byArrData[i];
what is the problem?
Thanks in advance
|
|
|
|
|
Susanmat wrote: clsCommand.byArrData
is null, I guess.
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 )
|
|
|
|
|
it's b'coz u just declare the array in the class but initialize it in the fnCommand function.
u shud call that function first and then use the array object.
e.g.
CCommand clsCommand = new CCommand();
clsCommand.fnCommand();
cls.byArrData[i]...
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
Susanmat wrote: Its showing error in this line
clsCommand.byArrData[i];
what is the problem?
The name of the member is byArray , not byArrData .
If that's not the actual problem, you should show the actual code that you are using instead of some code that you are not using. It's hard to find an error in your code by looking at something that is not.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi,
Can anybody help me out how to use http protocol as a transportation in socket programming.
|
|
|
|
|
Hi All,
I have a text file having german text. The Text contains some special characters like 'ß','Ä','Ü' etc. i want to convert the text using codepage 850. But after conversion it is showing garbage for above characters.This might happen because these characters are incorrectly translated due to incorrect coding of translation table for code page 850. What should i do to display these characters properly after conversion?
I am using following code for doing that
//Create a new stream for the input file
StreamReader stream = null;
stream = new StreamReader(@"D:\SampleGermanText.txt", Encoding.GetEncoding(850), true);
string strLine = stream.ReadLine();
while (stream.EndOfStream == false) //loop until end of the file.
{
LogMessage(strLine);
strLine = stream.ReadLine();
}
stream.Close();
Thanks,
Tushar
|
|
|
|
|
Either your input is wrong (maybe the file isn't using codepage 850, but Windows-1252?), or your output is wrong. What does the LogMessage function do to output the string?
|
|
|
|
|
Hi,
I have a COM object that is build for x64 platform. I wanted to debug this COM object with my C# TestDriver program (also used x64 platform).
When I enable "Enabled unmanaged code debugging", the application won't start. I gave me this error:
Error while trying to run project: Unable to start program 'C:\Temp\COM\TestDriver\TestDriver.exe'.
The debugger does not support debugging managed and native code at the same time on this platform.
Everything works fine for x86 platform (of course, my COM object also build for x86 platform).
Any idea?
Cheers
|
|
|
|
|
Hi All,
I created one personal folder in outlook.Now i wanna access that personal folder calendar events from c# program.i tried this but it directly access the default calender.i want to access which i created in outlook personal folder calendar.Give me any commends regarding this.
Thanx Much in Advance...
Mohan.T
Mohan t working for N.I.C
|
|
|
|
|
I am in a bit of a pickle. I need to write a windows application using Visual Studio 2005, I have an Accpac Financial System that has an API named XAPI.
What I did was that I will add this API as a reference and then insert the using namespace for the API, I have also added the namespace System.Runtime.InteropServices as this API works with an old COM component.
Now if I retrieve a value from the DB in the button_click event everything works. If I copy that code and put it in a method, say "public object Test()" and then reference the Test() in the button_click everything works.
Now I take that same code and copy that into a Class Library. I replace all the textboxes with property values as the textboxes cannot be accessed in the library. If I run the application I get a "Error HRESULT E_FAIL has been returned from a call to a COM component."
Can someone please help me with this?? I think it has something to do with the properties but I am not sure...
Thanks in advance!!
Illegal Operation
|
|
|
|
|
Are you accessing the class library from a console application? IIRC, console projects don't have the [STAThread] attribute set for Main, while WinForms projects do. Can you check whether the code accessing your library has [STAThread] set for its Main method?
|
|
|
|
|
I checked in the Program.cs and the [STAThread] has been set. It is a windows application that needs to execute methods from an external dll...
Illegal Operation
|
|
|
|
|
Hello everyone,
Sorry for this stupid question, as I am migrated from C++ to C#. In C++ there is no concept of property, except in COM.
For static property of a class in C# (e.g. DateTime.Now), I think there is nothing special compared to a non-static property, except we need to access the property by class name other than by instance variable name?
In my usage of static property, I feel no special point compared with static function. Correct?
thanks in advance,
George
|
|
|
|
|
You know properties are getter and setters and compiled into normal methods. Say you have property named "MyProperty" which will be compiled into get_MyProperty() and set_MyProperty() .
Non-static members are instance members which requires an instance for accessing. Statics are class members and can be accessed directly.
|
|
|
|
|
Thanks N a v a n e e t h,
Besides get/set methods, static property behaves the same like static member function?
regards,
George
|
|
|
|
|
Yes.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Good to learn from you Greeeg!
regards,
George
|
|
|
|
|
static in C# is the same as C++. It's just a matter of scope.
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 )
|
|
|
|
|
Thanks Chris!
Christian Graus wrote: a matter of scope
Means?
regards,
George
|
|
|
|
|
George_George wrote: In my usage of static property, I feel no special point compared with static function. Correct?
Properties help avoid adding a getter and setter function for every field that you want to expose - the resulting design looks cleaner, IMO.
|
|
|
|
|
|
George_George wrote: In my usage of static property, I feel no special point compared with static function. Correct?
In fact, DateTime.Now evaluates to public static DateTime get_Now() , so it's just a static get method. You can examine this in .NET Reflector.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
Hello everyone,
Here is my test program. I want to confirm that when we pass an out variable into a function, we just pass a reference, no additional copy is made?
class Program
{
struct Foo
{
public int abc;
}
static void Test(out Foo f)
{
f.abc = 200;
return;
}
static void Main(string[] args)
{
Foo f1;
f1.abc = 100;
Test(out f1);
Console.WriteLine(f1.abc);
return;
}
}
thanks in advance,
George
|
|
|
|