C#

C#: 02-Create Project

Create 'Essentials2017' Console App (.NET Core)


 

Solution Explorer Results


 

Program.cs is created with a Main method that accept arguments


 

using System;

namespace Essentials2017
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}

CTRL-F5 to Run program ( F5 to Debug)

Tags

C#: 01-.NET & .NET Core

.NET only windows

.NET Core works on many plaforms: win , linux, mac, mono – android, ios, windows phone

Tags

C#: Selenium Selectors

Drupal8 Logout Link at footer ( XPath vs LinkText )

  • Had MUCH difficulty hooking into the logout link using XPATH for
  • JS window.scrollTo
  • By.LinkText(“Log out”) seems to be more accessible
  • using By.LinkText allowed Selenium to natively 'scroll to' on the 'Click()' method

Selenium basic selectors

XPath

el = driver.FindElement(By.XPath("//a[@href='/uc/user/logout']"));

Id

el = driver.FindElement(By.Id("username"));

LinkText

el = driver.FindElement(By.LinkText("Log out"));

JS scrollIntoView

  • when element found by XPath(//a), this didn't work
el = driver.FindElement(By.LinkText("Log out"));
((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView(true);", el);

ILoc

Tags

C#: Classes - Base & Sub

  • To create a sub class,
  • add ' : <classname>' to the class statement
  • add :' base()' to the constructor
  •  


Base Class WITHOUT Arguments

  • If Base Class accepts NO arguments, the subclass doesn't need to include the 'base class constructor'
    class BaseClass
    {
        public BaseClass()
  • Constructor doesn't need an explicit reference to the base class
    class Base_SubClass : BaseClass
    {
       public Base_SubClass()
  • This is also valid & probably preferred

    class Base_SubClass : BaseClass
    {
       public Base_SubClass() : BaseClass() {}

Base Class WITH Arguments

  • If Base Class constructor TAKES arguments, the subclass constructor must include them explicitly

Tags

C#: MySQL ConnectorNET Connection Strings

MySQL Connector/Net

    Standard
    Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;

    Specifying TCP port
    Server=myServerAddress;Port=1234;Database=myDataBase;Uid=myUsername;
    Pwd=myPassword;

    The port 3306 is the default MySql port.

    The value is ignored if Unix socket is used.

    Multiple servers

    Use this to connect to a server in a replicated server configuration without concern on which server to use.
    Server=serverAddress1, serverAddress2, serverAddress3;Database=myDataBase;
    Uid=myUsername;Pwd=myPassword;

    Using encryption (old)

Tags
Subscribe to C#