Trending December 2023 # Vbscript Variable Declaration With Data Types: Dim, String, Boolean # Suggested January 2024 # Top 21 Popular

You are reading the article Vbscript Variable Declaration With Data Types: Dim, String, Boolean updated in December 2023 on the website We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested January 2024 Vbscript Variable Declaration With Data Types: Dim, String, Boolean

Variables form the basis of programming. Variables are used to hold value or an expression. Whenever you have a piece of data to work with, you will have to declare a variable.

For example, if you have to store names of students or salaries of employees, you will be using variables named students or salaries.

Variables can also be used for holding expressions. Suppose you have stored the marks of a student in English and Mathematics using the variables markE and markM.

You want to find the total marks. Then, you can use a variable named markT and set its value to markE + markM. In other words, markT = markE + markM. Here, markT is a variable which holds an expression.

In this tutorial, you will learn-

Declaring Variables

Declaring variables is the same as creating variables because you are instructing the computer to reserve memory space. You can name the variable the way you want. It can be short names like x, y or z or more self-describing names like student, Name, salary etc. Providing clear and meaningful names to variables is considered a good programming practice.

There are certain rules for VBScript variable names.

Variable name must begin with a letter. Examples: salary, mark etc. Variables beginning with numbers or special characters are not allowed. Examples: 1stSchool, 3rdCar, _name etc.

Variable name cannot exceed 255 characters.

Variable name should not contain a period (.).

For declaring variables, you need to use the keyword Dim. Suppose you plan to use a variable named “salary” in your VBScript program, syntax

Dim salary;

Just declaring the VBS variables will not help you, use it. You will have to assign a value to it at some point or another and this process is known as initializing the variable. If you are planning to declare a variably named salary, then you can code like this:

Dim salary salary = 10000

The important thing you need to make sure is that you should not assign a value to the variable as and when you declare it. Suppose you write a statement like this:

Dim salary = 10000

If you try to output salary using document.write, it will not return any output.

Code Example

Step 1) Open your text editor and add the following lines of code.

Dim variable1 variable1=”John” document.write(variable1) ‘Dim variable2 = “Smith” ‘document.write(variable2)

Step 2) Save this file as chúng tôi in your preferred location and then open this in IE (following the steps specified in the previous chapter). Now, you will see the value John on the browser.

Again save the file and refresh the IE browser if it is already opened or open the file in the IE browser. You might be wondered to see nothing; neither John nor Smith. The problem here is that you tried to assign the value to the variable while declaring it which is not allowed.

Loose Binding

VBScript provides you the freedom to use variables without declaring it (called loose binding). For example, without having the statement Dim student, you can assign a value to the variable student like – student = “John”

But, it is not at all a good programming practice. If you use a variable without declaring it and misspell the same variable when you use it again, VBScript will not prompt you of the error.

So to make the code easier to read and to identify the errors, you should use the Option Explicit statement at the beginning of your code so that you will be forced to declare all your variables even if you forget to do so. To avoid variable type related issues, it is always good to specify the statement Option Explicit at the beginning of your VBScript code.

Code Example:

Step 1) Open your text editor and add the following lines of code.

Option Explicit ‘Dim markE, markM, markT markE=90 markM=86 markT=markE+markM document.write(“Your total marks is ” & markT & “.”)

Step 2) Save the file as chúng tôi in your preferred location. Now open the file in Internet Explorer and your screen is blank. Why ? because you have used option explicit but not declared variables before using them

Step 4) Save the chúng tôi file and refresh your browser. Now, your output will be like this:

Note – To concatenate two strings, you need to use “&”. In above example, its used inside document.write command. It is obvious that the calculation of total marks is wrong. Now just add the first statement Option Explicit at the beginning of VBScript code (without the Dim statement).

Save the file and see the output. You will get nothing as output which indicates that your code has some error. Here the error is you have not declared variables before using it even after specifying Option Explicit statement.

You can also declare variables using public and private keywords like a public student or private student. But, you have to be more careful while using these two keywords for declaring variables because it will change the scope of your variables.

You can also store multiple values in a single variable and such variables are known as VBScript array variables. Suppose, you want to store details like name, marks, address etc of 30 students. It will be really difficult to create and manage sets of 30 variables for names, marks, addresses and so on.

Instead, you can declare a single variable named students and store the names of all 30 students in this variable. In such case, you will declare the variable as Dim students(29) (array index starts from zero) and you will assign values as

students(0) = "John" students(1) = "Hannah" students(2) = "Kevin" ....... ....... students(28) = "Rose" students(29) = "Emma"

Similarly, you can create variables like marks, address etc to store the respective values of all 30 students. You can also create multidimensional arrays having up to 60 dimensions.

Code Example:

Open your text editor and add the following lines of code.

Option Explicit Dim students(19), marks(19) students(0) = “John” marks(0) = 95 students(1) = “Emma” marks(1) = “83” students(2) = “Kevin” marks(2) = 87

Here, we have stored details of only three students. You can add details of up to 20 students as we have set the size of the array as 20 (as index starts from 0).

VBScript Data Types

In the previous section, you might have noticed that we assigned different types of data to the chúng tôi have stored numbers (mark and salary), strings (name) etc in different variables.

These numbers, strings etc are known as data types. In fact, VBScript has only one data type called Variant. A variant is a special kind of data type which can hold different kinds of information.

If you use Variant in a numeric context, it behaves like a number and when you use it in a string context, it behaves as a string.

In other words, when you specify salary=10000, VBScript assumes that salary is a numeric data type. A Variant makes specific distinctions about the nature of the data. For example, you can use variant type to store Boolean values, currency, date and so on.

These different categories of information that can be contained in a Variant are called subtypes. Though most of the time, Variant behaves in such a way that is most appropriate for the data it contains, you should be aware of different subtypes.

Following is the list of VBScript Data Types.

Empty: A special subtype to represent a variable that has not been assigned with any value yet.

Null: A special subtype to represent a variable assigned with a null value.

Integer: Using 2 bytes to express signed integer in the range -32,768 to 32,767.

Long: Using 4 bytes to express signed integers ranging from -2,147,483,648 to 2,147,483,647.

Single: Using 4 bytes to express real numbers in floating-point format ranging from -3.402823e38 to -1.401298e-45 for negative values, and from 1.401298e-45 to 3.402823e38 for positive value.

Double: Using 8 bytes to express real numbers in floating-point format ranging from -1.79769313486232e308 to -4.94065645841247e-324 for negative values, and from 4.94065645841247e-324 to 1.79769313486232e308 for positive values.

Currency: Using 8 bytes to express real numbers in decimal format ranging from -922,337,293,685,477.5808 to 922,337,293,685,477.5807.

Date: Using 8 bytes to express dates ranging from January 1, 100 to December 31, 9999.

String: Using 1 byte per character to express a sequence of characters that can be up to approximately 2 billion characters.

Object: A special subtype to represent a reference to an object.

Error: A special subtype to represent an error number.

Boolean: Using 2 bytes to contain either True or False.

Byte: Using 1 byte to express integer in the range 0 to 255.

There are two built-in VBScript functions that help you know the subtype of a variable: “varType()” and “typeName()”.

The var type returns the numeric representation and typeName() returns the text representation of the subtype of the variable. Each subtype has a predefined numeric representation.

Code Example

Open your text editor and add the following lines of code.

Option Explicit Dim a a = Empty

Dim b b = Null

Dim c c = 4

Dim d d = -2100483648

Dim e e = -3.402823E38

Dim f f = “John”

Dim g g = True

Save the file as chúng tôi and open it in IE. Your output will look like this:

NOTE: You can also declare variables using public and private keywords like public student or private student. But, you have to be more careful while using these two keywords for declaring variables because it will change the scope of your variables.


Variables are used to hold value or an expression while programming. Variables are to be declared and initialized separately.

Though you can use variables without declaring, declaring variables before using them is considered as a good programming practice.

A variant is the only data type of VBScript and variant has different subtypes including String, Boolean, Integer, Currency etc.


In case you see a blank page after you run the code, do the following

Press F12 to open developer tools

In left toolbar scroll down until you see “Emulation” settings page

Change Document Mode from a default (“Edge”) to 10

Add the following code to the head

You're reading Vbscript Variable Declaration With Data Types: Dim, String, Boolean

Extract Columns With A String In Column Name Of An R Data Frame.

To extract columns with a particular string in column name of an R data frame, we can use grepl function for column names and then subset the data frame with single square brackets.

For Example, if we have a data frame called df and we want to extract columns that has X in their names then we can use the command mentioned below −

df[grepl("X",colnames(df))] Example 1

Following snippet creates a sample data frame −

Students_Score<-sample(1:50,20) Teachers_Rank<-sample(1:5,20,replace=TRUE) Teachers_Score<-sample(1:50,20) df1<-data.frame(Students_Score,Teachers_Rank,Teachers_Score) df1

The following dataframe is created

   Students_Score Teachers_Rank Teachers_Score 1              37             3             42 2              50             4             15 3               8             5             21 4              29             3             35 5              10             5              3 6               2             2             41 7              12             4           29 8               1             4 44 9              41             2 10 10             39             3 39 11             27             3 43 12             18             1 48 13             44             5 12 14             21             4 16 15             16             3 20 16             45             5 50 17             17             1 31 18             49             1 30 19             47             5 17 20             32             5 8

To extract columns of df1 that contains Score in column name on the above created data frame, add the following code to the above snippet −

Students_Score<-sample(1:50,20) Teachers_Rank<-sample(1:5,20,replace=TRUE) Teachers_Score<-sample(1:50,20) df1<-data.frame(Students_Score,Teachers_Rank,Teachers_Score) df1[grepl("Score",colnames(df1))] Output

If you execute all the above given snippets as a single program, it generates the following Output −

 Students_Score Teachers_Score 1            37             42 2            50             15 3             8             21 4            29             35 5            10              3 6             2             41 7            12             29 8             1             44 9            41             10 10           39             39 11           27             43 12           18             48 13           44             12 14           21           16 15           16 20 16           45 50 17           17 31 18           49 30 19           47 17 20           32 8 Example 2

Following snippet creates a sample data frame −

Hot_Temp<-sample(33:50,20,replace=TRUE) Cold_Temp<-sample(1:10,20,replace=TRUE) Group<-sample(c("First","Second","Third"),20,replace=TRUE) df2<-data.frame(Hot_Temp,Cold_Temp,Group) df2

The following dataframe is created

  Hot_Temp Cold_Temp  Group 1       47         4  Third 2       33         5  First 3       36         2  Second 4       35         8  Second 5       33         8  First 6       44         1  Third 7       33         8  Third 8       46         3  First 9       36         3  Third 10      44         6  First 11      43        10  Third 12      35         9  First 13      36         4 Third 14      44         5 Second 15      48         5 Second 16      37         6 Second 17      35         5 Second 18      42         4 First 19      40         4 Second 20      42 4 Third

To extract columns of df2 that contains Temp in column name on the above created data frame, add the following code to the above snippet −

Hot_Temp<-sample(33:50,20,replace=TRUE) Cold_Temp<-sample(1:10,20,replace=TRUE) Group<-sample(c("First","Second","Third"),20,replace=TRUE) df2<-data.frame(Hot_Temp,Cold_Temp,Group) df2[grepl("Temp",colnames(df2))] Output

If you execute all the above given snippets as a single program, it generates the following Output −

 Hot_Temp Cold_Temp 1     47         4 2     33         5 3     36         2 4     35         8 5     33         8 6     44         1 7     33         8 8     46         3 9     36         3 10    44         6 11    43        10 12    35         9 13    36         4 14    44         5 15    48         5 16    37         6 17    35       5 18    42 4 19    40 4 20    42 4

Types And Criteria With Example

Definition of Non-Controlling Interest

Start Your Free Investment Banking Course

Download Corporate Valuation, Investment Banking, Accounting, CFA Calculator & others


The portion of the interest is left out after the holding company’s claim. For example, Zee Ltd wants to acquire 60% of the equity shares of B Ltd, so in this case, out of 100% holding of B Ltd, 60% will be given to Zee. Now Zee will be the holding company, and the rest of the shares % which is 40%, will be considered as Non-controlling interest. They will not allow to manage any company affairs and not require interfering in the company’s decisions. Sometimes a situation arises when there are losses in the company, so in that case, the losses which apply to the It is combined subsidiary may exceed the non-controlling interest of the single subsidiary. The non-controlling interest holders get the share as per the confined % of the controlling interest they share in the company.





Holding Company

Controlling Interest (80%)

Non controlling interest ( 20%)

Share Capital    800,000.00                     640,000.00             160,000.00

Reserve      60,000.00                       48,000.00               12,000.00

   860,000.00                     688,000.00             172,000.00


There are two types of non-controlling interest: direct non-controlling interest and another is Indirect non-controlling interest.

In direct non-controlling interest, the minority shareholders, i.e., those who are non-controlling interest bearing in the company, will get the profits to share of pre and post-acquisition. In contrast, in the case of indirect non-controlling interest, only post-acquisition profits are shared with the minority interest holders, and the pre-acquisition profits are not shared. The non-controlling Interest holders get a share of this distribution as per their controlling interest percentage in the company.

Criteria for Non-Controlling Interest Recording of Non-Controlling Interest

First of all, we must find that the acquisition is on which date.

Then find out the company which acquires and the company which is acquiring.

Calculation of Pre-acquisition and Post-acquisition profits are done.

Calculation of Pre-acquisition and Post-acquisition of reserves and surpluses are done.

In the next step, the distribution of profits takes place.

The Minority Interest record is under the head of Equity and Liability.

Minority Interest is separately recorded in the Balance sheet with its own name.


Non-Controlling Interest holders can anyway get access to the company’s financial books.

Taking a small share as a minority interest holder in a very emerging business can help the growth of individual investors.

The Non-Controlling Interest holders can see the business developments and get an insider’s view to plan their investment in such a way.

In most cases, the minority interest holders gain a huge average return on their funds since they know the company’s norms.

The risk also subsides because a huge investment does not require from the minority interest holders, and thus they can enjoy the benefit of the low risk and more gains on returns.

In the case of a business sale, the minority interest holder can sell part of this stake without many legal complications.


It is a very wide term. Minority shareholders of the company are not allowed to participate in the company’s meetings, but sometimes they can make a decision for the board members. If the board’s performance is not satisfactory, then the minority shareholders can ask the board to take action against them. In the corporate, the minority interest holder meeting and voting can be very influential. Non-controlling Interest holder also makes huge profits and returns on their investment in the company. They make very little investment per the company’s emerging business but can gain huge profits. Non Controlling Interest also gets their share in case of an acquisition. It is given emphasis in the Balance Sheet and is shown as a separate item.

Recommended Articles

Jsp Elements – Declaration, Syntax & Expression

JSP Declaration

A declaration tag is a piece of Java code for declaring variables, methods and classes. If we declare a variable or method inside declaration tag it means that the declaration is made inside the servlet class but outside the service method.

We can declare a static member, an instance variable (can declare a number or string) and methods inside the declaration tag.

Syntax of declaration tag:

Here Dec var is the method or a variable inside the declaration tag.


In this example, we are going to use the declaration tags

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"

Explanation the code:

Code Line 10: Here we are using declaration tag for initializing a variable count to 10.

When you execute the above code you get the following output:


The variable which is declared in the declaration tag is printed as output.

JSP Scriptlet

Scriptlet tag allows to write Java code into JSP file.

JSP container moves statements in _jspservice() method while generating servlet from jsp.

For each request of the client, service method of the JSP gets invoked hence the code inside the Scriptlet executes for every request.

A Scriptlet contains java code that is executed every time JSP is invoked.

Syntax of Scriptlet tag:


In this example, we are taking Scriptlet tags which enclose java code.

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" <% int num1=10; int num2=40; int num3 = num1+num2; out.println("Scriplet Number is " +num3);

Explanation of the code:

Code Line 10-14: In the Scriptlet tags where we are taking two variables num1 and num2 . Third variable num3 is taken which adds up as num1 and chúng tôi output is num3.

When you execute the code, you get the following output:


The output for the Scriptlet Number is 50 which is addition of num1 and num2.

JSP Expression

Expression tag evaluates the expression placed in it.

It accesses the data stored in stored application.

It allows create expressions like arithmetic and logical.

It produces scriptless JSP page.


Here the expression is the arithmetic or logical expression.


In this example, we are using expression tag

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"

Explanation of the code:

Code Line 12: Here we are using expression tags where we are using an expression by multiplying two numbers i.e. num1 and num 2 and then adding the third number i.e. num3.

When you execute the above code, you get the following output:


The expression number is 120 where we are multiplying two numbers num1 and num2 and adding that number with the third number.

JSP Comments

Comments are the one when JSP container wants to ignore certain texts and statements.



<%@ page language="java" contentType="text/html; charset=ISO-8859-1"

Explanation of the code:

When you execute the above code you get the following output:


We get the output that is printed in println method. Comments are ignored by container

Creating a simple JSP Page

A JSP page has an HTML body incorporated with Java code into it


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"

Explanation of the code:

Code Line 1: Here we are using directives like language, contentType and pageEncoding. Language is Java and content type is text/html with standard charset ISO 8859. Page encoding is standard charset.

Code Line 14: Here we are declaring variables num12 and num32 initializing with 12.

Code Line 15: Here we are using an expression where we are multiplying two numbers num12 and num32.

Code Line 16: Here we are fetching today’s date using date object.

When you execute the above code, you get the following output


We are printing overhere,

This is guru JSP example.

The number is num12*num32 (12*12).

Today’s date is the current date

How to run simple JSP Page

JSP can be run on web servers or application servers.

Here we will be using a webserver, and we can deploy it on the server enclosing it in a war application.

We can create JSP in an application (war).

This is an application which has following directory structure, and the application has to be build.

This application has to be built, and the following message will appear after the build is successful:

After the application is built then, the application has to be run on the server.

From the diagram, following points are explained:

There are two options either to choose a server or manually add the server to this application. In this case, we have already added JBoss server to the application hence, we select the existing server.

Once we select the server the server option is shown in point 2 which server we want to select. There can be multiple servers configured on this application. We can select one server from all those options

In the below screenshots, you can notice that our JSP program gets executed, and the test application is deployed in JBoss server marked in the red box.

Directory Structure of JSP

In directory structure, there is a root folder which has folder WEB-INF, which has all configuration files and library files.

JSP files are outside WEB-INF folder

Directory structure of JSP


In this example there is test application which has folder structure has following:


In this article, we have learnt about syntactic elements like expression tags, Scriptlet tags which simplify code in JSP.

We have created a simple JSP page and made it run on the server.

Types And Benefits Of Recourse Loan With Example

What is a Recourse Loan?

Start Your Free Investment Banking Course

Download Corporate Valuation, Investment Banking, Accounting, CFA Calculator & others

Key Takeaways

Some of the key takeaways of the article are:

A recourse loan is a financing instrument in which the lender can seize the collateral and any other assets in the defaulter’s name to recover the debt money.

Examples of other assets include other bank deposits, income sources, etc.

A recourse loan is backed by collateral and the borrower’s liability. Hence, the lender has to assume significantly lower risk in this type of loan.

Although there are many different recourse loans, the two most common types are hard money loans and auto loans. Not all mortgages are recourse loans, but the hard money loans in real estate purchases are recourse loans.

Examples of Recourse Loan

Let us now look at the following example to understand the concept of recourse loans.

Four years back, John got a stable job in a multinational company with an annual package of $75,000. Three months after joining the job, he purchased a house worth $300,000 in the countryside. However, when he checked his savings account, he realized that he had a savings of $60,000, which he decided to use as equity in this real estate purchase. So, he approached a bank for a housing loan of $240,000.

Unfortunately, today John defaulted on the bullet payment, and the lender immediately seized his house for foreclosure and subsequent recovery of the debt from the sale, resulting in proceeds of $75,000. So, the remaining $75,000 (= $150,000 – $75,000) plus the interest cost will be recovered through garnishment, wherein the outstanding loan balance will be directly deducted from his monthly paycheck until the entire loss amount is settled.

In this way, the recovery of losses occurs in a recourse loan when the borrower defaults.

Types of Recourse Loan

Hard money loans: In the case of a real estate acquisition, a hard money loan is considered a recourse loan because its terms give the lender the right to take possession of the borrower’s property after default and then resell it for a more significant gain.

Auto loans: Since the value of automobile cars depreciates over a period, which exposes the lenders to the risk of adequate recovery in the event of a default. Hence, most auto loans are recourse loans in nature.

Benefits of Recourse Loan

Some of the significant benefits of a recourse loan are as follows:

Some assets adequately back it in the form of collateral. Besides, there is the total liability of the borrower, which means that the lender doesn’t need to bear too much risk.

Borrowers get recourse loans as per their credit profile and financial position. People with good credit histories are offered favorable interest rates, while those with poor credit histories can get the loan on the back of their unlimited liability.

With such flexibility in lending terms, these loans result in the maximum flow of money in an economy through more frequent and easy lending.

First, the borrowers who default on a recourse loan may lose much more than the collateral provided because the lender invariably goes after the borrower’s other assets and income stream to recover the outstanding loan balance.

Further, the borrower who fails to repay a recourse loan loses not just the money, but such an event can be a very traumatic experience for them. It can get tricky for them to cope psychologically.


So, it can be seen that a recourse loan is a binding debt financing instrument that secures the lenders and makes their life much easier. But, on the other hand, it is not so favorable for the borrowers as they may be exposed to severe consequences in the event of a default. Hence, borrowers should consider all the aspects of the loans before signing up for any recourse loan.

Recommended Articles

A Quick Glance On Linq Join With Types

Introduction to LINQ Join

LINQ Join operator is used to join two or more data sources together based on the common field between them and retrieving the matched records from the collection based on the particular conditions. Thus, it is fetching the data from two or more data sources based on the similar properties that appear in the data sources. Thus, the functionality of the operator is similar to SQL Joins.

Start Your Free Software Development Course

LINQ Join Types

LINQ Join operates on two or more data sources; in other words, you can say as inner collection and outer collection from those both collection it returns a new collection it contains the records/data from both collections.

Syntax of LINQ Join:

The above syntax contains two overloaded methods to execute the join methods; it contains the comparer as an additional argument.

When working with LINQ Join, we must understand the five things.

Outer data source.

Inner data source.

Outer key selector can able to see the common key in the outer data source.

Inner key selector can able to see the common key in the inner data source.

Result selector to retrieve the data into the resultant set.

In LINQ Join, there are several types; let’s see the types of joins with their syntax with some examples.

1. INNER Join

Inner join is used to retrieve the matching records from both the data sources based on the specific conditions, and the non-matching will be eliminated from the resultant set.


Var _innerJoin=dataSource_1.getRecords_1 () .join(dataSource_2.getRecords_2() { _name=data.Name, .... }).ToList(); 2. LEFT Join

Left Join retrieves the records from the left collection and only the matching records from the right collection.


Var Left_Join= dataSource_1.getRecords_1 () .GroupJoin(dataSource_2.getRecords_2(), { data1,data2 { ........ }); 3. CROSS Join


Var Cross_Join=data1.records2() . Join(data2.records2(), { .. }); 4. GROUP Join

Group Join works similar to the join operator, whereas Group Join retrieves the result in groups based on a specific group key. Group Join performs the joining of two collections based on key and groups by the matching key and finally returns the collection of grouped key and result.


Var Group_Join=data1.records1() .GroupJoin( data2.records2(), ); Example of LINQ Join

Below is the example mentioned:


using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Console_LinQJoins { class Program { public class EmployeeClass_Master { public int Emp_ID { get; set; } public string Emp_Name { get; set; } public string Emp_Qualification { get; set; } public int Emp_DeptID { get; set; } } public class DepartmentClass_Master { public int Dept_ID { get; set; } public int Emp_ID { get; set; } public string emp_DeptName { get; set; } public int Emp_Salary { get; set; } } class Linq_Joins_ProgramClass { static public void Main() { new EmployeeClass_Master() {Emp_ID = 1000, Emp_Name = "Richard", Emp_Qualification = "MCA",Emp_DeptID=101}, new EmployeeClass_Master() {Emp_ID = 1005, Emp_Name = "Ricky", Emp_Qualification = "B.E",Emp_DeptID=103}, new EmployeeClass_Master() {Emp_ID = 1001, Emp_Name = "Jack", Emp_Qualification = "MCA",Emp_DeptID=101}, new EmployeeClass_Master() {Emp_ID = 1007, Emp_Name = "Ponting", Emp_Qualification = "B.E",Emp_DeptID=102}, new EmployeeClass_Master() {Emp_ID = 1003, Emp_Name = "Paul", Emp_Qualification = "M.Sc",Emp_DeptID=102}, new EmployeeClass_Master() {Emp_ID = 1004, Emp_Name = "Beeja", Emp_Qualification = "B.E",Emp_DeptID=103}, }; { new DepartmentClass_Master() {Dept_ID=101,Emp_ID = 1000, emp_DeptName = "Graphical-Designing", Emp_Salary = 60000}, new DepartmentClass_Master() {Dept_ID=102,Emp_ID = 1001, emp_DeptName = "Development", Emp_Salary = 35000}, new DepartmentClass_Master() {Dept_ID=103,Emp_ID = 1002, emp_DeptName = "Admin", Emp_Salary = 45000}, }; var res_CrossJoin = empDetails .Join(deptDetails, { Name = emp.Emp_Name, dName = dept.emp_DeptName } ); var res_GroupJoin = deptDetails. GroupJoin( empDetails, ); Console.WriteLine("nnLINQ Group Join"); foreach (var item in res_GroupJoin) { Console.WriteLine("ntDepartment Name :" + item.dept.emp_DeptName+"n"); foreach (var employee in item.emp) { Console.WriteLine("ttEmployeeID : " + employee.Emp_ID + " , Name : " + employee.Emp_Name); } } Console.WriteLine("nLINQ Cross Join"); Console.WriteLine("tEmployee NametDepartment Namesn"); foreach (var data in res_CrossJoin) { Console.WriteLine("nt{0}tt{1}", data.Name, data.dName); } Console.ReadLine(); } } } }

In this output, we can’t see the Employee Name “Paul” because this employee does not belong to any department.


In the above sample program, we used Group join and Cross join. In cross join, we need to map each element in the first collection with each element in the second collection, so cross join is nothing but it produces the Cartesian products of the collection. For example, in the above code, the first list of collections contains 6 elements, and the second collection contains 3 elements, so finally, the resultant collection will be (6*3) totally of 18 elements.


In this article, we well-read about LINQ Joins, which are used to return the collection of elements based on given conditions using joins. Using several types of join methods, we can easily retrieve our records in the desired way based on several criteria.

Recommended Articles

This is a guide to LINQ Join. Here we discuss the introduction along with the LINQ join types for a better understanding. You may also have a look at the following articles to learn more –

Update the detailed information about Vbscript Variable Declaration With Data Types: Dim, String, Boolean on the website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!