Google

Sunday, October 28, 2007

New Features in Visual Studio 2008 (code-named Orcas)

  • LINQ (Language Integrated Query) new versions of C# and VB languages ,
  • WPF(Windows Presentation Foundation) visual designer ,
  • A new HTML/CSS editor influenced by Microsoft Expression Web
  • Default configures compiled assemblies to run on .NET Framework 3.5
  • XAML based designer (codenamed Cider)
  • Workflow designer
  • LINQ to SQL designer
  • XSLT debugger
  • XSD designer
  • JavaScript Intellisense support
  • JavaScript Debugging support
  • support for UAC manifests
  • An enhanced set of UI widgets, both for WinForms and WPF
  • J# will not be included

Interview and Viva Questions for Oracel

Which command should be issued before you can execute the CREATE DATABASE command?
http://www.coolinterview.com/interview/4655

How many control files are required to create a database?
http://www.coolinterview.com/interview/4651

If you have two redo log groups with four members each, how many disks does Oracle recommend to keep the redo log files?
http://www.coolinterview.com/interview/4684

What is the difference between groupby and orderby?
http://www.coolinterview.com/interview/8560

What does OFA stand for?
http://www.coolinterview.com/interview/4657

Which SHUTDOWN option will wait for the users to complete their uncommitted transactions?
http://www.coolinterview.com/interview/4637

If the application is running very slow? At what points you need to go about the database in order to improve the performance?
http://www.coolinterview.com/interview/10944

Which is not a system privilege? a. SELECT b. UPDATE ANY c. EXECUTE ANY d. CREATE TABLE
http://www.coolinterview.com/interview/4800

15. Which keyword should be used in the CREATE INDEX command to create a function –based index? A. CREATE FUNCTION INDEX… B. CREATE INDEX … ORGANIZATION INDEX C. CREATE INDEX… FUNCTION BASED … D. None of the above
http://www.coolinterview.com/interview/4782

Which of the following statements may require a temporary segment? a. CREATE TABLE b. CREATE INDEX c. UPDATE d. CREATE TABLESPACE
http://www.coolinterview.com/interview/4773

What are the recommended INITIAL and NEXT values for a temporary tablespace, to reduce fragmentation?
http://www.coolinterview.com/interview/4700

What are the valid status codes in the V$LOGFILE view?
http://www.coolinterview.com/interview/4683

How many ARCn processes can be associated with an instance?
http://www.coolinterview.com/interview/4682

What is the biggest advantage of having the control files on different disks?
http://www.coolinterview.com/interview/4679

Which data dictionary view provides information on the version of the database and installed components?
http://www.coolinterview.com/interview/4668

Who owns the data dictionary?
http://www.coolinterview.com/interview/4666

How many data files can be specified in the DATAFILE clause when creating a database?
http://www.coolinterview.com/interview/4664

How do you correct a procedure that has become invalid when one of the tables it is referring to was altered to drop a constraint?
http://www.coolinterview.com/interview/4662

Which script creates the data dictionary views?
http://www.coolinterview.com/interview/4659

When creating a database, where does Oracle find information about the control files that need to be created?
http://www.coolinterview.com/interview/4658

Which view has information about users who are ghranted SYSDBA or SYSOPER privilege?
http://www.coolinterview.com/interview/4649

13. User SCOTT has opened a SQL * Plus session and left for lunch. When you queired the V$SESSION view, the STATUS was INACTVE. You terminated SCOTT’s session in V$SESSION?
http://www.coolinterview.com/interview/4643

I WANT TO BECOME A DBA ADMINISTRATOR. SO,FOR THAT WHAT CAN I PREPARE NOW?
http://www.coolinterview.com/interview/11583

What is Trigger at one Line?
http://www.coolinterview.com/interview/11340

Explaint the nvl2 function
http://www.coolinterview.com/interview/10943

What is the process of upgrading oracle forms /reports from older version to new versions?
http://www.coolinterview.com/interview/8559

How many codds rule should oracle satisfies
http://www.coolinterview.com/interview/8558

What is the difference between object library and pl/sql library
http://www.coolinterview.com/interview/8557

List out differences between Oracle Server 9i and Oracle Server 10g.
http://www.coolinterview.com/interview/8556

Explain truncate with restore option with example
http://www.coolinterview.com/interview/8555

What is the difference between Anonymous Block and subprogram? Can we call a procedure from Anonymous PL/SQL block?
http://www.coolinterview.com/interview/8554

How to get a calender in date field in oracle forms?
http://www.coolinterview.com/interview/8553

I have a server with 2GB RAM.Who is the optimal size for the shared pool size The shared pool reserved size is 1/10 to shared pool size Is there a mathematic type for compute the shared pool size ?
http://www.coolinterview.com/interview/8552

I want to know that..is there any special way to login into oracle SQL*PLUS Editor directly..Rather than every time u have enter user,password,host string...what should i do with login.sql script.. i Put it in /Bin directory..but not working..
http://www.coolinterview.com/interview/8551

Explaint the nvl2 function
http://www.coolinterview.com/interview/8550

When transporting a tablespace from one database to another, it should be a. Read-only. b. Offline. c. Online. d. Tablespace status does not matter.
http://www.coolinterview.com/interview/4817

Which NLS parameter can be specified only as an environment variable? a. NLS_LANGUAGE b. NLS_LANG c. NLS_TERRIROTY d. NLS_SORT
http://www.coolinterview.com/interview/4816

Which parameter in the export file is used to specify a structure –only export (no rows)? a. ROWS b. TABLE c. NODATA d. DIRECT
http://www.coolinterview.com/interview/4815

What does the parameter DIRECT=Y in the export parameter file signify? a. When exporting table data, bypass the SQL buffer cache and read the data blocks directly form the disk to the export file. b. When exporting table data, bypass the SQL processing layer and read data from disk to the buffer cache, and copy them directly to the export files c. When importing data using the export file create, write data blocks directly to the file, rather than going through the buffer. d. To perform a direct import, the export file must be created sing the direct method.
http://www.coolinterview.com/interview/4814

Choose the statement that is not true. Direct-path load a. Disables insert triggers on the table and enables them after the load completes. b. Disables referential integrity constraints and enables them after the load completes. c. Disables unique constraints and enables them after the load completes. d. Does not disable any constraints or triggers.
http://www.coolinterview.com/interview/4813

Which utility would you use to refresh the test table with production data? a. SQL*Loader conventional path b. SQL * Loader direct path c. Export/import d. SQL * Plus direct-load insert
http://www.coolinterview.com/interview/4812

To use the transportable tablespace feature, the block size of the target and source database should be a. 4KB b. Same size c. Not larger that 16KB d. Different size
http://www.coolinterview.com/interview/4811

If you run the ALTER SESSION SET NLS_DATE_FORMAT + ‘DDMMYY” statement, which dictionary view would you query to see the value of the parameter? a. V$SESSION_PARAMETERS b. NLS_SESSION_PARAMETERS c. NLS_DATABASE_PARAMETERS d. V$SESSION
http://www.coolinterview.com/interview/4810

Choose two reasons why you would use a direct –path load instead of a conventional-path load. a. To restrict users from performing b. To perform parallel loads c. To disable the generation of redo log entries if the database is in ARCHIVELOG mode. d. The table has many indexes, and the temporary tabelspace is small.
http://www.coolinterview.com/interview/4809

Which two parameters must you specify when importing the metadata information into the target database while transporting tablespaces? a. DATAFILES b. TABLESPACES c. TRANSPORT_TABLESPACE d. TTS_OWNERS
http://www.coolinterview.com/interview/4808

Choose two NLS parameters that cannot be modified using the ALTER SESSION statement. a. NLS_CHARACTERSET b. NLS_SORT c. NLS_NCHAR_CHARACTERSET d. NLS_TERRITORY
http://www.coolinterview.com/interview/4807

20. Which command is used to define CONNECT and RESOURCE as the default roles for user JAMES? a. ALTER USER b. ALTER ROLE c. SET ROLE d. SET PRIVILEGE
http://www.coolinterview.com/interview/4806

19. What is accomplished when you issue the following statement? ALTER USER JOHN DEFAULT ROLE ALL; a. John is assigned all the roles created in the database b. Future roles granted to John will not be default roles c. All of John’s roles are enabled, except the roles with passwords d. All of John’s roles are enabled when connecting to the database
http://www.coolinterview.com/interview/4805

18. How do you enable a role? a. ALTER ROLE b. ALTER USER c. SET ROLE d. ALTER SESSION
http://www.coolinterview.com/interview/4804

Which role in the following list is not a predefined role from Oracle? a. SYSDBA b. CONNECT c. IMP_FULL_DATABASE d. RESOURCE
http://www.coolinterview.com/interview/4803

16. To grant the SELECT privilege on the table CUSTOMER to all users in the database, which statement would you use? a. GRANT SELECT ON CUSTOMER TO ALL USERS; b. GRANT ALL ON CUSTOMER TO ALL; c. GRANT SELECT ON CUSTOMER TO ALL; d. GRANT SELECT ON CUSTOMER TO PUBLIC;
http://www.coolinterview.com/interview/4802

Which data dictionary view can be queried to see whether a user has the EXECUTE privilege on a procedure? a. DBA_SYS_PRIVS b. DBA_TAB_PRIVS c. DBA_PROC_PRIVS d. SESSION_PRIVS
http://www.coolinterview.com/interview/4801

Which clause should be specified to enable the grantee to grant the system privilege to other users? a. WITH GRANT OPTION b. WITH ADMIN OPTION c. CASCADE d. WITH MANAGE OPTION
http://www.coolinterview.com/interview/4799

Which view would you query to see whether John has the CREATE TABLE privilege? a. DBA_SYS_PRIVS b. DBA_USER_PRIVS c. DBA_ROLE_PRIVS d. DBA_TAB_PRIVS
http://www.coolinterview.com/interview/4798

User JAMES has a table named JOBS created on the tablespace USERS. When you issue the following statement, what effect will it have on the JOBS table? ALTER USER JAMES QUOTA 0 ON USERS; a. No more rows can be added to the JOBS table b. No blocks can be allocated to the JOBS table c. No new extents can be allocated to the JOBS table d. The table JOBS cannot be accessed
http://www.coolinterview.com/interview/4797

Which clause in the CREATE USER command can be used to specify no limits on the space allowed in tablespace APP_DATA?
http://www.coolinterview.com/interview/4796

Which dictionary view shows the password expiration date for a user?
http://www.coolinterview.com/interview/4795

Which password parameter in the profile definitions can restrict the user from using the old password for 90 days?
http://www.coolinterview.com/interview/4794

Which resource specifies the value in minutes?
http://www.coolinterview.com/interview/4793

6. When a new user is created, and you do not specify a profile, a. Oracle prompts you for a profile name. b. No profile is assigned to the user. c. THE DEFAULT profile is assigned.
http://www.coolinterview.com/interview/4792

What is the maximum number of profiles that can be assigned to a user?
http://www.coolinterview.com/interview/4791

4. Choose the option that is not true. a. Oracle creates a profile named DEFAULT when the database is created. b. Profiles cannot be renamed. c. DEFULT is a valid name for a profile resource. d. The SESSIONS_PER_USER resource in the DEFAULT profile initially has a value of 5.
http://www.coolinterview.com/interview/4790

3. Which resource is not used to calculate the COMPOSITE_LIMIT? a. PRIVATE_SGA b. CPU_PER_SESSION c. CONNECT_TIME d. LOGICAL_READS_PER_CALL
http://www.coolinterview.com/interview/4789

2. Which command is used to assign a profile to an existing use? a. ALTER PROFILE b. ALTER USER c. SET PROFILE d. The profile should be specified when creating the user; it cannot be changed.
http://www.coolinterview.com/interview/4788

1. Profiles cannot be used to restrict. a. CPU time used b. Total time connected to the database c. Maximum time a session can be inactive d. Time spent reading blocks
http://www.coolinterview.com/interview/4787

What is the difference between a unique constraint and a primary key constraint?
http://www.coolinterview.com/interview/4786

Which script creates the CHAINED_ROWS table? A. catproc.sql B. catchain.sql C. utlchain.sql D. No script is necessary: ANALYZE TABLE LIST CHAINED ROWS creates the table.
http://www.coolinterview.com/interview/4785

A constraint is created with the DEFERRABLE INITIALLY IMMEDIATE CLAUSE. What does this mean?
http://www.coolinterview.com/interview/4784

Which data dictionary view shows statistical information from the ANALYZE INDEX VALIDATE STRUCTURE command?
http://www.coolinterview.com/interview/4783

14 Which component is not part of the ROWID? A. Tablespace B. Data file number C. Object ID D. Block ID
http://www.coolinterview.com/interview/4781

13. Which line in the following code has an error? 1. ALTER TABEL MY_TABLE 2. STORAGE ( 3. MINEXTENTS 4 4. NEXT 512K) 5. NOLOGGING;
http://www.coolinterview.com/interview/4780

What clause is in the ALTER TABLE command is used to reorganize a table?
http://www.coolinterview.com/interview/4779

Which keyword is not valid of the BUFFER_POOL parameter of the STORAGE clause?
http://www.coolinterview.com/interview/4778

When validating a constraint, why would you specify the EXCEPTIONS clause?
http://www.coolinterview.com/interview/4777

A table is created with an INITRANS value of 2. Which value would you choose for INITRANS of an index created on this table?
http://www.coolinterview.com/interview/4776

Fill in the blank: The parameter MAXTRANS specifies the maximum number of concurrent transactions per ___________________.
http://www.coolinterview.com/interview/4775

How does Oracle determine the extent sizes for a temporary segment? A. From the initialization parameters B. From the tables involved in the sort operation C. Using the default storage parameters for the tablespace D. The database block size
http://www.coolinterview.com/interview/4774

Which two initialization parameters are used by ORACLE to determine the number of rollback segments required for an instance? a. ROLLBACK_SEGMENTS b. TRANSACTIONS c. TRANSACTIONS_PER_ROLLBACK
_SEGMENT d. PROCESSES
http://www.coolinterview.com/interview/4772

What can cause the Snapshot too old error?
http://www.coolinterview.com/interview/4771

What is row migration?
http://www.coolinterview.com/interview/4770

Which data dictionary view can be queried to see the OPTIMAL value for a rollback segment? A. DBA_ROLLBACK_SEGS B. V$ROLLSTAT C. DBA_SEGMENTS D. V$ROLLNAME
http://www.coolinterview.com/interview/4717

What is the default value of PCTFREE?
http://www.coolinterview.com/interview/4716

How can you fix the MAXEXTENTS reached error for a rollback segment?
http://www.coolinterview.com/interview/4715

What type of rollback segment is used if a tablespace containing an active transactions taken offline?
http://www.coolinterview.com/interview/4714

When does Oracle stop adding rows to a block?
http://www.coolinterview.com/interview/4713

Which portion of the data block stores information about the table having rows in this block?
http://www.coolinterview.com/interview/4712

What is the minimum number of extents a rollback segment can have?
http://www.coolinterview.com/interview/4711

Which data dictionary view would you query to see the free extents in a tablespace?
http://www.coolinterview.com/interview/4710

6. Choose the statement used to manually de-allocate the extents used by a rollback segment. A. ALTER ROLLBACK SEGMENT R01 DEALLOCATE; B. ALTER ROLLBACK SEGMENT RO1 DROP EXTENTS; C. ALTER ROLLBACK SEGMENT RO1 SHRINK; D. ALTER ROLLBACK SEGMENT RO1 SIZE 10K.
http://www.coolinterview.com/interview/4709

5. Which storage parameter is applicable only to rollback segments? A. PCTINCREASE B. MAXEXTENTS C. TRANASACTIONS D. None of the above.
http://www.coolinterview.com/interview/4708

What happens if you create a rollback segment in the same tablespace where application data is stored? Choose the best answer. A. The tablespace will be fragmented. B. Performance improves, because when changes are made, undo information can be written to the same tablespace. C. There should be a minimum of two data files associated with the tablespaces when rollback segments are created. D. None of the above is true.
http://www.coolinterview.com/interview/4707

Which parameter specifies the number of transaction slots in a data block?
http://www.coolinterview.com/interview/4706

When a table is updated, where is the before image information (which can be used for undoing the changes) stored?
http://www.coolinterview.com/interview/4705

Place the following logical storage structures in order-from the smallest logical storage unit to the largest. A. Segment B. Block C. Tablespace D. Extent
http://www.coolinterview.com/interview/4704

19. If you issue ALTER TABLESPACE USERS OFFLINE IMMEDIATE, which of the following statements is true? A. All data files belonging to the tablespace must be online. B. Does not ensure that the data files are available. C. Need not doe media recovery when bringing the tablespace online. D. Need to do media recovery when bringing the tablespace online.
http://www.coolinterview.com/interview/4703

How would you determine how much sort space is used by a user session?
http://www.coolinterview.com/interview/4702

Which statement is true regarding the SYSTEM tablespace? A. Can be me made read only. B. Can be offline. T C. Data files can be renamed. D. Data files cannot be resized
http://www.coolinterview.com/interview/4699

14. Which statement is false? A. Dictionary-managed temporary tablespace can be made permanent. B. The size of the locally managed temporary tablespace file cannot be changed. C. Once created, the extent management of a tablespace cannot be altered. D. A locally managed permanent tablespace cannot be made temporary.
http://www.coolinterview.com/interview/4698

13. The database block size is 4KB. You created a tablespace using the following command. CREATE TABLESPACE USER_DATA DATAFILE ‘C:/DATA01.DBF’; If you create an object in the database without specifying any storage parameters, what will be the size of the third extent that belongs to the object?
http://www.coolinterview.com/interview/4697

Tuesday, October 9, 2007

Interview questions for .Net for Freshers

What is Class
A user-defined data structure that groups properties and methods. Class doesn’t occupies memory.

What is Object
Instance of Class is called object. An object is created in memory using keyword “new”.

What is .Net Platform?
Microsoft .NET is a software development platform based on virtual machine architecture.
    Dot Net Platform is:
  • Language Independent – dot net application can be developed different languages (such as C#, VB, C++, etc.)
  • Platform Independent – dot net application can be run on any operating system which has .net framework installed.
  • Hardware Independent – dot net application can run on any hardware configuration It allows us to build windows based application, web based application, web service, mobile application, etc.
What is .Net Framework?
.Net Framework provides a foundation upon which .net application and xml webservices are built and executed.

Two main Components of .Net Framework
  • 1. Common Language Runtime
  • 2. Base Class Library.

Difference between Struct and Class
  • Struct are Value type and are stored on stack, while Class are Reference type and are stored on heap.
  • Struct “do not support” inheritance, while class supports inheritance. However struct can implements interface.
  • Struct should be used when you want to use a small data structure, while Class is better choice for complex data structure.

What is the difference between instantiating structures with and without using the new keyword?
When a structure is instantiated using the new keyword, a constructor (no-argument or custom, if provided) is called which initializes the fields in the structure. When a structure is instantiated without using the new keyword, no constructor is called. Hence, one has to explicitly initialize all the fields of the structure before using it when instantiated without the new keyword.


What do you mean Encapsulation in oops
Wrapping up of data and function into a single unit is known as Encapsulation.
Example of encapsulation: class.

How to use Properties in .Net
Attribute of object is called properties. Eg1:- A car has color as property.
Example:
private string m_Color;;

public string Color
{
get
{
return m_Color;
}
set
{
m_Color = value;
}
}

Car Maruti = new Car();
Maruti.Color= “White”;


Console.Write(Maruti.Color);



Isn't it better to make a field public than providing its property with both set { } and get { } block? After all the property will allow the user to both read and modify the field so why not use public field instead? Motivate your answer.

Not always! Properties are not just to provide access to the fields; rather, they are supposed to provide controlled access to the fields of our class. As the state of the class depends upon the values of its fields, using properties we can assure that no invalid (or unacceptable) value is assigned to the fields.
Example:
private int age;

public int Age
{
get
{
return age;
}
set
{
if(value <> 100)
//throw exception
else
age = value;
}
}

Note : All these questions are taken from dailyfreecode.com

Wednesday, October 3, 2007

Source code of cat command of Unix

/* $OpenBSD: cat.c,v 1.14 2002/07/04 04:26:39 deraadt Exp $ */
/* $NetBSD: cat.c,v 1.11 1995/09/07 06:12:54 jtc Exp $ */

/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Kevin Fall.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/


#ifndef lint
static char copyright[] =
"@(#) Copyright (c) 1989, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */

#ifndef lint
#if 0
static char sccsid[] = "@(#)cat.c 8.2 (Berkeley) 4/27/95";
#else
static char rcsid[] = "$OpenBSD: cat.c,v 1.14 2002/07/04 04:26:39 deraadt Exp $";
#endif
#endif /* not lint */

#include <sys/param.h>
#include <sys/stat.h>

#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

extern char *__progname;

int bflag, eflag, nflag, sflag, tflag, vflag;
int rval;
char *filename;

void cook_args(char *argv[]);
void cook_buf(FILE *);
void raw_args(char *argv[]);
void raw_cat(int);

int
main(int argc, char *argv[])
{
int ch;

setlocale(LC_ALL, "");

while ((ch = getopt(argc, argv, "benstuv")) != -1)
switch (ch) {
case 'b':
bflag = nflag = 1; /* -b implies -n */
break;
case 'e':
eflag = vflag = 1; /* -e implies -v */
break;
case 'n':
nflag = 1;
break;
case 's':
sflag = 1;
break;
case 't':
tflag = vflag = 1; /* -t implies -v */
break;
case 'u':
setbuf(stdout, NULL);
break;
case 'v':
vflag = 1;
break;
default:
(void)fprintf(stderr,
"usage: %s [-benstuv] [-] [file ...]\n", __progname);
exit(1);
/* NOTREACHED */
}
argv += optind;

if (bflag || eflag || nflag || sflag || tflag || vflag)
cook_args(argv);
else
raw_args(argv);
if (fclose(stdout))
err(1, "stdout");
exit(rval);
}

void
cook_args(char **argv)
{
FILE *fp;

fp = stdin;
filename = "stdin";
do {
if (*argv) {
if (!strcmp(*argv, "-"))
fp = stdin;
else if ((fp = fopen(*argv, "r")) == NULL) {
warn("%s", *argv);
rval = 1;
++argv;
continue;
}
filename = *argv++;
}
cook_buf(fp);
if (fp != stdin)
(void)fclose(fp);
} while (*argv);
}


void
cook_buf(FILE *fp)
{
int ch, gobble, line, prev;

line = gobble = 0;
for (prev = '\n'; (ch = getc(fp)) != EOF; prev = ch) {
if (prev == '\n') {
if (sflag) {
if (ch == '\n') {
if (gobble)
continue;
gobble = 1;
} else
gobble = 0;
}
if (nflag && (!bflag || ch != '\n')) {
(void)fprintf(stdout, "%6d\t", ++line);
if (ferror(stdout))
break;
}
}
if (ch == '\n') {
if (eflag && putchar('$') == EOF)
break;
} else if (ch == '\t') {
if (tflag) {
if (putchar('^') == EOF || putchar('I') == EOF)
break;
continue;
}
} else if (vflag) {
if (!isascii(ch)) {
if (putchar('M') == EOF || putchar('-') == EOF)
break;
ch = toascii(ch);
}
if (iscntrl(ch)) {
if (putchar('^') == EOF ||
putchar(ch == '\177' ? '?' :
ch | 0100) == EOF)
break;
continue;
}
}
if (putchar(ch) == EOF)
break;
}
if (ferror(fp)) {
warn("%s", filename);
rval = 1;
clearerr(fp);
}
if (ferror(stdout))
err(1, "stdout");
}


void
raw_args(char **argv)
{
int fd;

fd = fileno(stdin);
filename = "stdin";
do {
if (*argv) {
if (!strcmp(*argv, "-"))
fd = fileno(stdin);
else if ((fd = open(*argv, O_RDONLY, 0)) < rval =" 1;" filename =" *argv++;" wfd =" fileno(stdout);" buf ="=" bsize =" MAX(sbuf.st_blksize," buf =" malloc((u_int)bsize))" nr =" read(rfd,"> 0)
for (off = 0; nr; nr -= nw, off += nw)
if ((nw = write(wfd, buf + off, nr)) < rval =" 1;">

Some difference between VB.Net and C#

Make your case

In my opinion, the biggest difference (by far) between VB.NET and C# is the fact that C# is case-sensitive. This can be a problem for former Visual Basic or current VB.NETers to grasp as they move to C#. After all, the following is legal in C#:

stringfirstName;

string FirstName;

string Firstname;

These three variables are unique with no problems, but the same (or similar) VB.NET code will not compile since each variable is seen as having the same name:

Dim firstName As String

dim FirstName As String

Dim Firstname As string

Other languages like JavaScript and Java are case-sensitive, so this isn't an anomaly—rather developers may view VB.NET's lack of case-sensitive support as out-of-the-ordinary.

Delimiters

Another major difference in the languages is line termination and code blocks. VB.NET uses a carriage return at the end of each line, so lines of code are contained on their own line. On the other hand, C# code lines use the semi-colon at the end of each line of code. Each line of code does not need to be on its own line, but it must end with a semi-colon. If you forget a semi-colon, you'll encounter a code error.

A block of code is a collection of statements. Examples include a class, its methods, loops, and so forth. C# marks a code block with curly braces (the starting brace { and the ending brace }) while VB.NET ends code blocks with statements (such as End If, Next, and End Sub). The following C# code snippet declares a class with a constructor with the curly braces defining the groups:

public class TestClass {

public TestClass() {

// Constructor

}

~TestClass() {

// Destructor

}

public void DoSomething() { }

public intDoSomethingElse() {}

}

And, VB.NET uses end statements to delineate a code block:

Class TestClass

Public Sub New()

' Constructor

End Sub

Protected Overrides Sub Finalize()

REM Destructor

End Sub

Public Sub DoSomething()

End Sub

Public Function DoSomethingElse() As Integer

End Function

End Class

These code snippets demonstrate the approach to blocks of code—most notably, a class declared with two methods. Actually, the code demonstrates a few other points. Each class declares constructor and destructor methods as well as two methods. The first method (DoSomething) does not return a value, while the second method (DoSomethingElse) does. You'll notice that VB.NET uses Sub for methods that return no values and Function for its counterpart. C# uses void for no return value and specifies the return value otherwise. The code also uses comments.

The C# comments are single-line with the double backslashes (//); multi-line comments may be used as well—they are enclosed as a group between backslash and asterisk combinations (/* and */). VB.NET only supports single-line comments denoted with either the apostrophe (') or REM statement.

Data types

The two languages support the same data types with a few differences in syntax. The following table provides an overview.

VB.NET


C#

Boolean


bool

Byte


byte, sbyte

Char


char

Short, Integer, Long


short, ushort, int, unit, long, ulong

Single, Double


float, double

Decimal


decimal

Date


DateTime

Object


object

String


string

You may notice a big difference where C# supports unsigned values while VB.NET does not. Variable declaration presents differences as well. VB.NET uses the dim statement to declare (or dimension) a variable, and the as keyword is used to assign a type as the following lines demonstrate:

Dim i As Integer

Dim first As String

On the other hand, C# starts with the type followed by the name:

int I;

string first;

When working with variables and objects, you will often work with arrays where another syntax difference arises.

Brackets

One of the language differences that always seem to trip me up is the use of brackets by C# for accessing individual elements of an array or collection of values. On the flip side, VB.NET uses parentheses in the same situations. The following code declares and populates an array of integer values:

int[] test = {1,2,3,4,5};

for (int x=0; x < test.Length; x++) { Console.WriteLine(test[x]); };

Here's the equivalent VB.NET code:

Dim test() As Integer = {1, 2, 3, 4, 5}

For i As Integer = 0 To (test.Length - 1)
Console.WriteLine(test(i))

Next i

The code demonstrates the different syntax of the for loop as well.

Equality

The final discrepancy between the languages that I'd like to cover is the syntax for determining the equality of two values. This is a common misstep for developers new to C# (and JavaScript coders as well), as C# uses the double equals sign (==) to test for equality, while VB.NET uses the single equals sign (=). The following code samples demonstrate testing equality—beginning with C# that determines if an integer is equal to a value and displays text accordingly:

if (i == 2) { Console.WriteLine("They are equal"); }

else { Console.WriteLine("They are not equal"); }

Here's the VB.NET equivalent:

Dim i As Integer

If (i = 2) Then
Console.WriteLine("They are equal")

Else
Console.WriteLine("They are not equal")

End If

The frustrating aspect of this difference is it is not caught during compilation, so using the single equals sign in C# will assign the value instead of determining equality and thus logic problems that requires debugging.