answersLogoWhite

0

C Sharp

C Sharp is a programming language developed by Microsoft Corporation. It is designed to be a simple, general-purpose, modern, object-oriented programming language. The latest version is C# 4.0. It is designed for developing applications for both embedded and hosted systems.

343 Questions

What are difference between static and dyanamic assembly?

Static Assemblies: - These assemblies are .NET binaries located on the disk as a file or set of files and directly loaded from there as and when CLR requests for them. Whenever one compiles the C# code, one gets STATIC assemblies.

Dynamic Assemblies: - These assemblies are loaded directly from the Memory and not stored on the disk. However one can save them later to the disk. These binaries are created on the fly in the memory using SYSTEM.REFLECTION.EMIT namespace. Hence the name- dynamic.

What is void command in c sharp programming?

void simply means you don't have anything to return w/in a function, it is the same as return 0;

public void sample()

{

MessageBox.Show("This Function do not return anything");

}

What is the difference between C and C Sharp?

#1) C is unmanaged code, and C# is managed by the .NET CLR (Common Language Runtime)

Managed code means that many of the low-level activities that one has to worry about with C, such as memory management, garbage collection, pointers, etc, are automatically handled for you.

#2) C# is an object orienated language. C is a structed language. However, if you were referring to C++, then both C# and C++ have similar (although not identical) object orienated capabilities.

AnswerC is a procedural programming language developed in AT&T-Bell labs. It has been in use for about four decades for system and application programming. It has been ported to lots of CPUs and operating systems.

C-sharp (C#) is an object oriented programming language developed by Microsoft for use in its .NET framework. It is much newer, and only works on Microsoft operating systems. C#, like many other programming languages, is a descendant of C - they share some syntactic conventions.

What is an instance of a class Red many definitions of a constructor But did not understand the exact working of a constructor What is the main use of constructor how it works?

The consttructor creates a new instance of the class

for example the class shown below does not exist until the constructor is called, where it sets the class up for first use.

Class Dog

{

int _legs, _eyes;

string _breed;

//CONSTRUCTOR, this takes an input from the user which sets the breed of the dog, and sets the default number of legs and eyes.

public Dog(input)

{

_legs = 4;

_eyes = 2;

_breed = input;

}

}

if the user calls the constructor with the string "Labrador", that is one instance of the class, if the user calls it again with the string "terrier" that is another instance. the class is constructed like this:

//Class instancename = New class(parameters);

Dog lab = New Dog("Labrador");

hope this helps

Steve

To display an input string vertically by c?

// get input

char input[256];

gets(input);

// print one character on each line

int i;

for(i = 0; input[i] != '\0'; ++i) {

printf("%c\n", input[i]);

}

Can you run visual studio 2005 program in visual studio 2008?

NO [ and perhaps Yes, depends on the definition of "run" and visual studio 2005 program ].

 

The programs developed in VS 2005 must go thru the conversion steps for the projects, solutions, and possibly the language version, depends on the frameowork of the VS2008 is under, then it can be run (launched) from VS2008.  But you will not be able to convert the project or solution back to VS2005 easily.

[The runnable version of the program is a VS2008 program, not a VS2005, so technically, you did not have a VS2005 program running in VS2008]

 

The dll files (class libraries) created in VS2005 may be referenced by any modules in VS2008.

[dlls are not runnable at DEVELOPMENT time, the referencing part, and it has no tied to VS2005.  So technically when you run a program in VS2008 with a supporting dll file created from VS2005, you are not really running a VS2005 program]

 

Is c language a secure programming language?

C is coming around to being defined as a secure language, but older drafts of C, such as C91 and C99, are inherently insecure. The design philosophy of the day was "trust the programmer," which of course meant that it had to be insecure because the programmer might want to do something unexpected, such as accessing a hardware port directly or dropping in some optimized assembler code that manipulated pointers in an unusual pattern that a specific piece of hardware requires.

Today's C (C11) is more robust and offers new features, and is less likely to "trust the programmer" than older drafts, but it still allows inherently insecure actions. Other languages that are derivatives of C (such as C# or C++) are more secure. For example, C# is staticallyanalyzable-- the Common Language Runtime that underpins this and other .Net languages can assert that the program will not crash, handle memory references incorrectly, or otherwise perform in a way that could cause system instability. Even then, however, a programmer may mark code as "unsafe", which disables static analysis and requires the user to accept the risks of running the application.

Can an object be created from a main or non-main class?

please clarify the question. I have a feeling that the question is not asking what I am about to answer here.

You may have a class named "main" in the program.

I presume non-main means any class that is not main.

Can an object be created from a class (named main or non-main)? It depends on how you design that class. Ususally yes.

How do you create a Pascal triangle using only one 'for' loop using C?

int factorial (int n)

{

if (n==0) return 1;

else return (n*factorial(n-1));

}

int combo (int n, int r)

{

return (factorial (n))/(factorial (r) * (factorial (n-r)));

}

int width(int n, int i, int j)

{

return(j==0?(((n+1)*2)-((i==0)?i:(i-j))):(j<=3)?j+1:j-1);

}

void print (int n)

{

int i, j;

for (i = 0; i<=n; ++i)

{

for (j = 0; j<=i; ++j)

{

printf ("%*d", width(n,i,j) ,combo (i, j));

if (i==j)

{

printf("\n");

}

}

}

}

int main ()

{

int row,col;

int maxrow;

printf("\nPlease enter the num of rows for pascal triangle : ");

scanf("%d",&maxrow);

printf("The Pascal Triangle for %d rows is :\n",maxrow);

print(maxrow);

printf("To get the value at any row, col please enter \nRow:");

scanf("%d",&row);

printf("Col:");

scanf("%d",&col);

printf("\nThe value at row %d & col %d is : %d\n",row,col,combo(row,col));

}

What is attribute in csharp?

Attribute by itself is a class itself in C#. An instance of this class (or the derived class) may be applied to some elements in the program, at runtime, design time or both.

I also came across some developers using "attribute" to refer to data members!!

So, to get a better answer, perhaps should ask a better/clear-cut question.

How do you convert text into binary in vb or c sharp code?

C# EXAMPLE

String text="My sample data";

System.Text.ASCIIEncoding encode=new System.Text.ASCIIEncoding();

//convert to binary and store in a byte[]
byte[] binaryArray=encode.GetBytes(text);

What is abrstac class and virctul function in c?

I have to assume the question is for C#, not C, because C does not provide abstract class concept.

public abstract class A1 { public virtual void SayHi() { Console.WriteLine("Hello World"); }

public abstract void DoSomething();

}

The above abstract class A1 contains 1 virtual method and 1 abstract method. [Note that because of the abstract keyword for Dosomething(), A1 must be declared as abstract. An abstract class DOES NOT have to have any abstract methods!!)

The virtual function SayHi() provides a implementation, while the abstract function provides nothing but only the method signature( the name of the method, the return type, and method parameters and their data types). The derived class of A1 has the option to override SayHi() and must implement (or defer to subclasses of this derived class) the method DoSomething()

What is dotnet?

Microsoft's applications development framework.

Most commonly written as: ".Net".

Can You Write Trigger in Stored Procedures?

A trigger is a stored procedure. It is a special stored procedure that runs in response to some defined event, such as an insert into a table.

What is the use property in net?

  1. As to access a data member of an object or class (a class can have property, or static property).
  2. A property may have different accessing modifiers (new in .net 2.0) separately for the getters and setters (the mutators)
  3. .Net framework itself uses and depends on Property feature heavily.

One of the rookie mistakes or being a lazy developer is to allow the data members being directly accessed (get and set the values) as a public field:

public class Person { public string Name; }

vs

public class BetterPersonImplementation {

public string Name {

get;

set;

}

} //the new way to declare a data member via property declaration

The first benefit of moving from direct access to Property implementation is now your class can be directly apply to a window forms (direct field access cannot!!)

The hidden benefit - you are following the object principles - encapsulation

You are denying the public to directly playing with aPerson's Name. (If it were a body part.... yak)

The other benefit: if when setting the name value, let's assume that it should never be set to "Name", and there are more than 10 assignments in your code assignements aPerson.Name = ....

You would have to insert the check "if the value != "Name" at 10 different places.

Worse yet, someone else uses your class in their codes, you have to notify them as well.... (well, you won't make this kind of mistake if someone is going to use your code in the first place, right?)

By using Property feature, you have only 1 place to make the change, while the 10 assignments (the property setter) remain the same!

What keyword is using to create objects?

In C# and Visual Basic.NET the keyword is "new". C doesn't have such an animal, but you generally use the library call to malloc to get new memory.

What triggers xanthophobia?

Like all fears and phobias, xanthophobia is created by the unconscious mind as a protective mechanism. At some point in your past, there was likely an event linking the color yellow or the word yellow and emotional trauma. Whilst the original catalyst may have been a real-life scare of some kind, the condition can also be triggered by myriad, benign events like movies, TV, or perhaps seeing someone else experience trauma. But so long as the negative association is powerful enough, the unconscious mind thinks: "Ahh, this whole thing is very dangerous. How do I keep myself from getting in this kind of situation again? I know, I'll attach terrible feelings to the color yellow or the word yellow, that way I'll steer clear in future and so be safe." Just like that xanthophobia is born. Attaching emotions to situations is one of the primary ways that humans learn. Sometimes we just get the wiring wrong. The actual phobia manifests itself in different ways. Some sufferers experience it almost all the time, others just in response to direct stimuli. Everyone has their own unique formula for when and how to feel bad.

What is YouTube automation system?

I don't believe there is a specific feature called "YouTube Automation System". YouTube does, however, have an automated Content ID System that helps copyright owners identify content used without their permission.

Why my Wireless connection is not working on my laptop?

Wireless problemsI have a similar problem with my laptop. I have a Fujitsu-Siemens Lifebook, one that has been great over the past year for college, etc. However, my wireless internet connection suddenly went off the other day with no warning, with the modem showing that there was no local network and the laptop showing no available connection.

First thing to do - check wireless is turned on. It sounds basic, but sometimes the switch can get knocked, meaning that the laptop won't recieve any wireless signal. If this doesn't work, play around with the settings for a while - if you're running Windows you can go to 'network connection' in Control Panel and right-click on your wireless connection; go to 'repair' and the repair wizard will go through it to try and fix it. Make sure both the wireless switch on your laptop is turned on, and that your modem is turned on too.

If this doesn't work, go to your modem's setup page (usually a web page - the address will be in the manual) and choose a different wireless channel - 0, 6 and 11 are the only non-overlapping channels. You may want to adjust your wireless signal power to make sure you have enough signal. You might also want to run a diagnostic on your modem to see if it is running properly. Some modems will display on the setup page which computers are active. See if yours comes up.

If this still doesn't work, you may want to go to an internet cafe or other wireless hotspot to check whether it is your modem which is at fault. If you get a signal and can connect, then it may well be the modem at fault. Check at some other locations just to be sure. If not, it sounds like the wireless card has a problem. If it is an internal wireless card, you might want to take it back to the manufacturer for repair. If it is an external wireless adapter, you may just want to replace the card or adapter to see if this helps.

What are NET Applications?

.NET Applications are any application developed in Microsoft Visual Studio in any .NET language (including C# and VB.NET).

.NET applications can be both windows applications and web applications.

How do you use exception in c sharp?

Exceptions are the error handling mechanism of C#. When an error occurs, an exception is thrown using this syntax:

void BadMethod()

{

bool Error = true;

if (Error)

{

throw new Exception("Whoops!");

}

}

Methods can then handle exceptions using a try/catch/finally syntax. The code that you are trying to execute goes between a try { } block, the code to handle the error goes between the catch { } block. Any code that you put between the finally { } block will always execute after the exception handling code is complete (or if an error did not occur).

void test()

{

try

{

BadMethod();

catch (Exception ex)

{

Console.WriteLine("An error occured. The description is: " + ex.Description);

}

finally

{

Console.WriteLine("I'm done!");

}

}

BPO design problem?

To answer to this question, (a) one has to define what architecture is and (b)what architecture is expected to do. Let me define what architecture is: Architecture involves creation of forms and spaces expected to enable the performing of certain functions, which may be intervened by quantitaive dimensions of form and space as much as qualitative characteristics of form and space. Specific people are involved whose previous spatial experiences of the world as well as future expectations have to be accounted for. (a) A good definition of architecture would thus be, "Architecture is the creation of forms and spaces so as to produce in the participants a definite spatial experience in relation to the previous and anticipated spatial experiences". (b) As can be seen, architecture is expected to produce definite spatial experiences. The question 'what is an architectural design problem' pre-suppopses that architecture is a problem solving activity. In that context, we may ask, what is the purpose of creating spatial experiences ? or which problem will the spatial experiences will resolve ? That indeed is the architectural design problem. If we look at architecture as a problem solving exercise, it deals with numerous problems. Among them are problems of site, problems of context, problems of structure, problems of climate, problems of internal environmental controls such as airconditioning etc. as well as mecahnical problems etc. Although a building deals with them, they are essentaily not the core of the architecture. As per our definition, creating a spatial experiences is made possible by these and they create their own problems. But they are not the critical architectural problems. The architectural problems are the ones that can be affected or resolved by the spatial experiences; which undeniably are social and psychological by nature. Thus the archiectural problems are those social and psychological aspects of 'being in' and 'using a piece of architecture' for the 'purpose for which that piece of architecture is intended'. By purpose, this means not the mundane function of a space but the underlying deep rooted, social and psyhological conditiions required for the performance of that function. An Architectural design problem therefore is the social/psychological condition necessary to be acquired by a user in order to perform the major/ the most significant activity of a given project. A project has more than one architectural design problem and they can be recognised as primary and secondary ones, depending on the nature of the functions and activities expected to be carried in a given project.

2 Create a Console application that gets the a number as input from the user and it should be reversed?

//This function reverse any given string, except null

static string Reverse(string s) {

char[] temp = s.ToCharArray();

Array.Reverse(temp);

return new string(temp);

}

//The main usage

string inputString = Console.ReadLine();

Console.WriteLine(Reverse(inputString));

What is the reference type and value type?

In C#, a reference type [of object] is an object created from a class, a value type is an object created from a struct.

2 value type of objects are identical if their value/state are the same, while reference type are identical only if their storage address are the same.

In C#, unless you can look at the definition of an object, usually you don't know the object is a value type or reference type.

public struct MyThing {}

public class Toy {}

MyThing cat = new MyThing();

MyThing dog = new MyThing();

Console.WriteLine(cat yours); // False