i want to include using.System.Transactions header file in c# program but i m not able to do that.

whats the problem i am not getting??

Recommended Answers

All 7 Replies

C# doesn't have header files. The using just allows you to reference objects in a namespace without having to fully specify the namespace (as long as there are no conflicts). For example:

using System.Transactions

public void MyMethod() {
    Transaction t1 = new Transaction();
    System.Transactions.Transaction t2 = new System.Transactions.Transaction();
}

The two lines in the method refer to the same class. The compiler knows to search all the namespaces specified in the using clauses for classes. The second one fully specifies the namespace so the compiler doesn't have to do a search.

Headers do not exist in C#.
You can say

using System;

using is a keyword, System is a namespace
I don't know what the System.Transaction namespace is.

thank you for reply but its still not allow me to write using System.Transactions

when i write this and compile it it gives me error like

The type or namespace name 'Transactions' does not exist in the namespace 'System' (are you missing an assembly reference?)

now tell me what to do/.....please reply fast

Headers do not exist in C#.
You can say

using System;

using is a keyword, System is a namespace
I don't know what the System.Transaction namespace is.

It's for creating your own transaction based system where you can do things like rollbacks in case you need to. For example, let's say you need to write a program to transfer money to another bank. This has several steps:

Notify other bank of amount/account.
Verify other bank got the right amount/account.
Subtract money from the account.
Verify that money was added to the other account.

If any of these fail, you want to make sure that you rollback the transaction so it is like it never happened. Otherwise you end up in an invalid state that causes everyone to be unhappy :)

thank you for reply but its still not allow me to write using System.Transactions

when i write this and compile it it gives me error like

The type or namespace name 'Transactions' does not exist in the namespace 'System' (are you missing an assembly reference?)

now tell me what to do/.....please reply fast

You need to add the reference. Right click on the references in the Solution Explorer and select Add Reference. Click the .NET tab, scroll down to System.Transactions and select it. Hit OK.

ya thank you i just add this references and its working properly...

Please mark the thread solved, then :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.