Is it mandatory to use array in foreach loop C-sharp can foreach be used without array?
Foreach is for an IEnumerable, not just an array (unless you are using C# 1.1 or earlier). A collection (List, Dictionary, etc) can also generate a sequence from foreach-statement. In fact, if you have a class that is NOT an array, but it implements all the required methods of IEnumerable, it may be applied as:
public class Storage: IEnumerable {...}
Storage myStorage = new Storage();
...
Foreach (Thing stuff in myStorage)
{...}
Which class is used to define the controls in c?
In .NET, the class name is System.Windows.Forms.Control
Is reader class is an abstract class?
For Java: Yes, Reader is an abstract class in package of java.io;
For C#: No, Reader is NOT one of the defined library classes. Of course you create one.
There is Int64 class, it will do it.
What is encapsulation in c sharp?
I think the question should be modified as "What is the encapsulation in Object-Oriented programming?" instead of in C#.
C# itself is not encapsulated. It supports OO programming, and encapsulation is one of the main characteristics of OO programming".
The encapsulation in plain English is to hide a piece of information (data) or behavior (the code) within the object itself. Outside of the object should not and cannot know about it.
For instance, let's say you want to add 1 to a property of an object:
Person me = new Person();
me.Wallet.Content += 1;
The above shows the traditional way of adding 1 to the content of my wallet. But if you examine the code carefully, it was like:
"give me all the contents in your wallet, I'll add 1 to those, then put the new contents back in". There is no encapsulation in that code segment.
Person me = new Person();
me.AddToWalletContent(1);
The above code segment shows a way of encapsulation. Noted that there is no property of Wallet, no property of Content of a Wallet directly being seen here.
That's the encapsulation in a nut shell.
How the object me (an instance of Person) implements AddToWalletContent(int aNumber) is not the concern of the consumer, and the consumer has no knowledge (does not know, and should not know) about the person has a wallet or not, and if he does, what the contents were before adding 1 to them.
I hope the above examples shed some lights about encapsulation in OO.
How do you execute all statement in try block if an exception occurs?
If you have an exception you should fix mistake in your try block. If you want to run some code even after exception was thrown you can use full form of try block:
try
{
...
}
catch (...)
{
...
}
finally
{
...
}
Where the statement finally is what you need. Make sure that the code you run within this statement is not able to trow exceptions.
Array is value type or reference type in CSharp?
Array is a class name, hence ought to be a value type.
Difference between NON-vsam datasets and vsam datasets?
VSAM files are used when we want to store data based on some key fields(Eg: KSDS)
access method is indexed.
NON VSAM files like PS are used when we want to store data which is not unique and also the access is sequential.
What is the diffrece between disconnected and connected environment?
Connected environment is one in which a user is required to be constantly
connected to the Data Source while performing any operation in-order to keep the data up-to-date, whereas in Disconnected environment no constant connection to the Data Source is required.
Moreover in connected environment the data concurrency effects can be
easily resolved but Connected environment causes network traffic. But in Disconnected environment since the user is not directly connected to the data source, the user can connect to the data source as and when required and hence it allows for Multiple applications to simultaneously interact with the Data Source. It also improves the scalability and performance of the applications.
Few more differences can be contributed as the Connected Environment uses Datareader while the Disconnected one uses Dataset. This results in the fact that Connected Environment is Slower in speed in comparison to Disconnected environment for DML Operations. But as far the Connected Environment is concerned we get updated data and less chances of Dirty read, whereas Disconnected environment suffers from the major problem of Dirty read.
Thanks & Regards,
Shoaib R Khan - SRK
Is System.String a class or a struct?
System.String is a class. However, it is somewhat unique in that it is immutable, meaning that it is readonly. So if you change the contents of a string, behind the scenes it creates a new string object and destroys the old one.
Write c sharp program to find sum of two numbers?
public int findSum(int n1, int n2) { return n1 + n2; }
A local error has occurred plus directoryservices?
There's Active directory on windows 2000 advance server, I have a web server on Windows 2008 server Enterprise Edition, the following code works fine in Winsows 2003 server but when I installed Win 2008 server, it gives me the following error
A local error has occurred.\r\n"} System.Exception system.DirectoryServices.DirectoryServicesCOMException}
I want to Authenticate Via AD from my webserver, I even test the port 389 and it was open. I don't know what's wrong on Windows 2008 server that cannot run my code, I search Internet but I found nothing.
any solution would be helpful.
Thank you
A .lib file, or a statically-linked library file, is a file which can contain information like: pre-written code; subroutines; classes; values; types e.t.c.
A library file offers functionality pre-built for drag-and-drop type usage, rather than requiring the programmer to include large numbers of classes or other information into their project.
What is value of enter key then how to get that value in c?
The new line character ('\n') has the ASCII value 10 decimal, 0x0A hexadecimal. In some cases, a new line may be preceded with a carriage-return (ASCII 13 decimal, 0x0D hexadecimal), however the carriage return is only of relevance to line printers.
To determine when the enter key is pressed, capture the character via stdin and test for equality with the '\n' character.
a class A infraction is when you are faceing a 10 to 15 year sentence