|
|
Are properties slow or fast to use? What I mean is: Isn't
class A
{
int i;
A()
{}
public int I
{
get { return i; }
set { i = value; }
}
}
A a = new A();
a.I = 5;
int b = a.I;
// slower than:
class A
{
public int i;
A()
{}
}
A a = new A();
a.i = 5;
int b = a.i;
And another question: if a function is called 100x a second (or more) which creates/returns objects (structs and classes) as data, won't this have an impact on performance (for real time stuff - for example user input) ?
If it is not efficient, what optimizations are possible or how should it be done properly?
Thank you in advance and don't kill beginners for stupid questions
|
|
|
|
|
The JIT compiler (only on the release version of your assemblies) will inline any method with less than 32 bytes of IL.
I see dumb people
|
|
|
|
|
Can you call processes on another machine via SSH using the C# base class library? I'm looking to be able to access Unix on another box and am ONLY allowed in via SSH or web services using SSL. I'm planning to build some web services, but would like the ability to get in via SSH.
Chuck King
|
|
|
|
|
|
Ok, something worries me about array types in C#. Two things actually, the first being the concrete type of an array of C# objects. The following:
SomeClass[] myArr = new SomeClass[10];
creates an object myArr that is of a type derived from System.Array , and specialised for objects of type SomeClass . My first question regards the [] operator. Where does it suddenly spring into the picture? It doesn't exist on objects of type System.Array . The type of the indexer for myArr above is SomeClass it seems, as the compiler won't let me make a statement like:
myArr[0] = new string;
and quite rightly so, complaining that string cannot be converted into SomeClass . Thus the indexer must be part of the interface of the automatically generated derived array type. The wierdness begins when I do this:
object[] mySameArr = myArr;
Console.Write (mySameArr[0]);
Now, this compiles and runs without a problem. How? The interfaces of the derived object[] and SomeClass[] types must be different, because each declares an indexer with a different signature. This probably shouldn't compile, or at least, shouldn't run, because despite SomeClass being derived from object , SomeClass[] is NOT derived from object[] ! What's going on? Does the C# compiler fudge this some way, or does the .NET CTS have different relationships between array types that doesn't fit my (somewhat C++ skewed) view? Is this some kind of mock-up of generics that seems like it will be broken once real generics are implemented?
My second, and maybe not so confusing, question regards pointers and arrays. This appears in MSDN:
public unsafe int Read(byte[] buffer, int index, int count)
{
int n = 0;
fixed (byte* p = buffer)
{
ReadFile(handle, p + index, count, &n, 0);
}
return n;
}
Can anyone tell me where the conversion is made between the byte[] specialisation of System.Array and byte* ? Is there a conversion operator defined in that subclass, or is there some other compiler funk going on?
Should I be poring through the C# standard? Thanks for any help, and please, if this has come up before (as I'm sure it would have) point me towards the old posting.
|
|
|
|
|
|
I need a way to get network status like connected or disconnected.
I have generated a class with mgmtclassgen and it throws exceptions
when tring to create the class. What is the best way to do this?
Thank you
Bo Hunter
Me
|
|
|
|
|
Are you using the System.Management and System.Management.Instrumentation namespaces? If so, then you can just use a WQL query with the ManagementQuery object and query whatever you want.
Hey, what can I say? I'm a chick magnet...a babe conductor...a logarithm for the ladies.
-Strong Bad from HomeStarRunner.com
Essential Tips for Web Developers
|
|
|
|
|
I am assuming you are using WMI to get the network status. The problem you may be that certain adapters do not have an actual instance when you check the status. For example the WAN Miniport (PPTP) will not have a status all the time (if it does at all). WHen you loop through your ManagementCollection you will get a NullReferenceException -
Bo Hunter wrote:
object ref not set to an instance
object ref not set to an instance. To get around this you should catch the error, or narrow your WQL. If there is a certain adapter you are checking for let me know. I will post some code. I hope this is along the lines of what you are after.
Matt is a network administrator for an insurance company in the midwest. He is shamelessly looking for Windows programming side work.
|
|
|
|
|
Hi,
I want to add my application to the registry for it to start at Windows startup (don't worry, user configurable).
I just can't find a way to get the fully qualified path of my main executable (including filename).
Any ideas?
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
|
Perfect! thank you very much!
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
Can anyone please recommend a book on Systems Analysis and Design? I have searched Amzon.com but found too many books and all were rated XXXXXX.
Jassim Rahma
|
|
|
|
|
|
I used StringFormat.Alignment and StringFormat.LineAlignment but nothing has changed What is in GDI+ similer with Win32 SDK DT_CENTER or DT_CENTER ?
Thanx
|
|
|
|
|
Hi,
Why I'm getting the following error when trying to connect to AS400 DB2?
RDB name not found or RDB does not match Remote LU name. Driver's SQLSetConnectAttr failed.
Test connection failed because of an error initializing provider. RDB name does not match. Remote LU name. SQLSTATE HY000 - 360
I have also attached the configuration....
Jassim Rahma
|
|
|
|
|
Have you installed DB2 Drivers etc on your machine properly. After that, the following connection strings should work:
For OLEDB:
Provider=IBMDADB2;Database=deepakdb;hostname=deepakdbsrv; port=50000;protocol=TCPIP;uid=dbuser; pwd=dbuser
For ODBC:
Driver=IBM DB2 ODBC Driver;Database=deepakdb;hostname=deepakdbsrv; port=50000;protocol=TCPIP;uid=dbuser; pwd=dbuser
But for ODBC and C#, you need to have Microsoft ODBC.NET Provider to be installed on the machine.
I am connecting to a DB2 on RS/6000 AIX Server with the above connection string and hence the above modus operandi should apply in your environment too.
Deepak Kumar Vasudevan
http://deepak.portland.co.uk/
|
|
|
|
|
I tried the OLE DB parameters you provided here but getting the following error:
The 'IBMDADB2' provider is not registered on the local machine.
I have already installed Microsoft Host Integration Server (HIS) on this machine and I'm able to connect using the 5250 Client.
Let us assume that I have the following information about my AS400 database:
User Id: JASSIM
Password: JSM999
Host IP Address: 152.458.526.458
Database: P325PXT
Library: EMOLIB
How can I connect to it?
Seems that you are an expert and I really need your help on this...
Many Thanks,
Jassim Rahma
|
|
|
|
|
Hi,
Seems that you are not using IBM Driver for DB2 and you are using Microsoft Supplied Driver for DB2. The driver I was mentioning in my reply would be installed when you install IBM DB2 Client and Application Development Tools on the machine.
Since you are using the driver from Microsoft, which comes as part of the Host Integration Server (HIS), you might have a different connection string.
Did u check the connectionstring syntax and other attributes with this URL:
http://www.connectionstrings.com/
Did this solve your query?
Deepak Kumar Vasudevan
http://deepak.portland.co.uk/
|
|
|
|
|
If I didn't install it, where can I get it on the web? can I download it from somewhere?
Jassim Rahma
|
|
|
|
|
|
sorry for asking too many silly questions but because I never used the .NET to access DB2 objects...
I have download the IBM provider and I'm not getting the registration error any more but getting other error (don't have it now) saying database not found.
I'm sure about the database name but I have not entered the library. I will tell you what information I have and can you tell me how to connect to it please.
User Id: JASSIM
Password: JSM999
Host IP Address: 152.458.526.458
Database: P325PXT
Library: EMOLIB
When I login using 5250 I get the system name as LIBRA (this is my system name based in UK) but all connections are based on IP.
Many Thanks,
Jassim Rahma
|
|
|
|
|
Hi!
With IBM DB2 Driver, you have some cool tools with which you can check out and manage your databases. You need to create a database alias and you can use the following tool to use Db2 Tools
Start -> Programs -> IBM Db2 -> Client Configuration Assistant
(You may elect Search the network for the wizard to identify your DB2 Server. But that normally doesn't work over the Internet. Hence you may like to choose 'Manually Configure' option)
Once this is done you can proceed with using DB2 Client Tools. But regarding the connection string. Did u use the pattern like this:
Provider=IBMDADB2;Database=yourdbname;hostname=databaseservername; port=dbinstanceport;protocol=TCPIP;uid=dbloginname; pwd=dbpassword
This should help you get connected to the database.
Deepak Kumar Vasudevan
http://deepak.portland.co.uk/
|
|
|
|
|
Hi,
Thank you very much for your help... I managed to connect to DB2 using your code.
I have question now, how can get more information about the DB2 database file (object), date last modified, file size, user last updated, etc?
Many Thanks,
Jassim Rahma
Jassim Rahma
|
|
|
|