Found 2628 Articles for Csharp

Explain and contrast value types and reference types in C#

Akshay Khot
Updated on 19-May-2021 07:33:11

224 Views

In general, all types in C# can be divided into two main categories − value types and reference types. Let's look at each type in detail.Value TypesVariables of value types directly contain their data. Each variable has its own copy of the data. Hence it is impossible for a variable of value type to modify another object.A value type can be one of the following types −all numeric types, e.g., int, float, and doublechar and the bool typesstruct type orenumeration type.A value type simple contains the value. For example, the integer type contains the actual number, and not a pointer ... Read More

C# and Selenium: Wait Until Element is Present

Debomita Bhattacharjee
Updated on 07-Apr-2021 08:45:02

6K+ Views

We can wait until an element is present in Selenium webdriver using the explicit wait. It is mainly used whenever there is a synchronization issue for an element to be available on page.The WebDriverWait and the ExpectedCondition classes are used for an explicit wait implementation. We have to create an object of the WebDriverWait which shall invoke the methods of the ExpectedCondition class.The webdriver waits for a specified amount of time for the expected criteria to be met. After the time has elapsed, an exception gets thrown. To wait for an element to be present, we have to use the ... Read More

Moving mouse pointer to a specific location or element using C# and Selenium

Debomita Bhattacharjee
Updated on 07-Apr-2021 08:38:51

6K+ Views

We can move mouse pointer to a specific location or element in Selenium webdriver(C#) using the Actions class. We have to first create an object of this class.Next to move an element we have to apply the MoveToElement method and pass the element locator as a parameter to this method. Finally, to actually perform this task the method Perform is to be used.After moving to an element, we can click on it with the Click method. To move to a specific location, we have to use the MoveByOffset method and then pass the offset numbers to be shifted along the ... Read More

How to open a browser window in full screen using Selenium WebDriver with C#?

Debomita Bhattacharjee
Updated on 07-Apr-2021 08:13:21

1K+ Views

We can open a browser window in full screen using Selenium webdriver in C# by using the method Maximize. This method has to be applied on the webdriver object.Syntaxdriver.Manage().Window.Maximize();Exampleusing NUnit.Framework; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using System; namespace NUnitTestProject1{    public class Tests{       String url = "https://www.google.com/";       IWebDriver driver;       [SetUp]       public void Setup(){          //object of FirefoxDriver          driver = new FirefoxDriver();       }       [Test]       public void Test1(){          //URL launch          driver.Navigate().GoToUrl(url);          //browser maximize          driver.Manage().Window.Maximize();          Console.WriteLine("Browser Maximized");       }       [TearDown]       public void closeBrowser(){          driver.Quit();       }    } }Output

Difference Between Interface and Abstract Class in Java & C#

AmitDiwan
Updated on 24-Mar-2021 13:13:43

464 Views

In this post, we will understand the difference between abstract class and interface in Java and C#.Abstract ClassIt contains the declaration and definition part.Multiple inheritance can’t be implemented using abstract class.It contains the constructor.It can also contain some static members.It can contain multiple types of access modifiers such as public, private, protected.The performance of an abstract class is very good, because it is quick.It is used to implement the core identity/functionality of a class.A class can use only one abstract class.If many implementations are same, and they have a common behaviour, it is suggested to use an abstract class.Abstract classes ... Read More

Difference Between ref and out in C#

AmitDiwan
Updated on 24-Mar-2021 13:09:58

718 Views

In this post, we will understand the difference between ‘ref’ and ‘out’ in C#.Ref keywordBefore passing the parameters to ‘ref’, they need to be initialized.It is not necessary to initialize the value of the parameter before it returns to the calling method.The data can pass in two directions when the ‘ref’ keyword is used.It is useful when the called method needs to change the value of the parameter that is passed.Out keywordIt is not required to initialize parameters before it is passed to ‘out’.It is required to initialize the value of a parameter before it is returned to the calling ... Read More

Difference Between Delegates and Events in C#

AmitDiwan
Updated on 24-Mar-2021 13:06:37

1K+ Views

In this post, we will understand the difference between delegates and events in C#.DelegateIt can be declared using the ‘delegate’ keyword.It is a function pointer.It holds the reference to one or more methods during runtime.It is an independent keyword.It doesn’t depend on events.It contains the Combine() and Remove() methods that help add methods to the list of invocation.It can be passed as a parameter to a method.The ‘=’ operator can be used to assign a single method.The ‘+=’ operator can be used to assign multiple methods to a delegate.EventIt can be declared using the ‘event’ keyword.It can be defined as ... Read More

Difference Between dispose() and finalize() in C#

AmitDiwan
Updated on 24-Mar-2021 12:47:38

988 Views

In this post, we will understand the difference between the methods ‘dispose’, and ‘finalize’ in C#.DisposeThis method is defined in the IDisposable interface.It has to be invoked by the user.Whenever it is invoked, it helps free the unmanaged resources.It can be implemented whenever a close() method is present.It is declared as public method.It is quick, and instantly disposes an object.Since it performs instantaneously, it doesn’t affect performance.FinalizeIt is a method that is defined in the java.lang.object class.It is invoked by the garbage collector.It helps free the unmanaged resources just before the object is destroyed.It is implemented to manage the unmanaged ... Read More

Difference Between C# and C++

AmitDiwan
Updated on 02-Mar-2021 04:56:56

439 Views

Let us first learn about C# and C++ −C# is a general-purpose object-oriented programming language.It is considered as a pure object-oriented programming language.It is pronounced as 'C sharp'.It was developed by Anders Hejlsberg and his team at Microsoft.Memory Management is done automatically by the garbage collector.It is the language's duty to automatically delete the object once its objective is completed.It is windows specific, i.e. it can't be used on all systems.It doesn't support multiple inheritance.The pointers in C# can only be used in the unsafe mode.It is considered as a high-level language.Once the code is compiled, it gets converted into ... Read More

How to perform a left outer join using linq extension methods in C#?

Nizamuddin Siddiqui
Updated on 05-Dec-2020 06:45:26

1K+ Views

With INNER JOIN only the matching elements are included in the result set. Non-matching elements are excluded from the result set.With LEFT OUTER JOIN all the matching elements + all the non-matching elements from the left collection are included in the result set.Let us understand implementing Left Outer Join with an example. Consider the following Department and Employee classes. Notice that, Employee Mary does not have a department assigned. An inner join will not include her record in the result set, where as a Left Outer Join will.Examplestatic class Program{    static void Main(string[] args){       var result = Employee.GetAllEmployees() ... Read More

Advertisements