-
MY PROJECTS
-
Recent Posts
- SQL.How can you compare two nullable values safely, and how does IS DISTINCT FROM differ from <>?
- SQL.How are NULL values ordered by ORDER BY, how do defaults differ between databases, and how can you control their placement?
- SQL.How does NULL propagate through arithmetic expressions, and how can COALESCE and NULLIF help handle missing values and division by zero?
- SQL.How does NULL affect join conditions, and why can filtering the right-hand table in WHERE remove unmatched rows from a LEFT JOIN?
- SQL.How do GROUP BY and DISTINCT treat NULL values, even though NULL = NULL evaluates to UNKNOWN?
- SQL.How do aggregate functions handle NULL, and what is the difference between COUNT(*), COUNT(column), and COUNT(DISTINCT column)?
- SQL.How does NULL affect IN and NOT IN, and why can NOT EXISTS be a safer choice when a subquery returns nullable values?
- SQL.How do WHERE, HAVING, and CHECK constraints treat conditions that evaluate to UNKNOWN?
- SQL.Why do column = NULL and column <> NULL not work as expected, and when should you use IS NULL and IS NOT NULL?
- SQL.What is SQL’s three-valued logic (TRUE, FALSE, UNKNOWN), and how do AND, OR, and NOT behave with UNKNOWN?
- ChromeDevTools.Watch all failed requests
- SQL.What are domain types (or constraints on data types), and how do they help enforce data correctness?
- SQL.How does SQL handle comparisons between different data types (for example, string vs number), and why is this dangerous?
- SQL.What is the difference between DATE, TIME, TIMESTAMP, and TIMESTAMPTZ, and which one should be used for business events?
- SQL.How do numeric types like INTEGER, BIGINT, DECIMAL, and FLOAT differ in terms of precision and use cases?
- SQL.What problems can arise from implicit type casting in SQL, and how can it affect indexes?
- SQL.How does NULL differ from 0, an empty string, or FALSE in SQL?
- SQL.What is the difference between CHAR, VARCHAR, and TEXT, and when would you choose each?
- SQL.What is MVCC ?
- SQL.What is AutoVacuum Postgres ?
Categories
- Aptana
- Azure
- C#
- DataSnap
- DBExpress
- Delphi
- Delphi и сети
- Delphi. Язык программирования
- ExtJS
- FastReport
- FireDAC
- FireMonkey
- GIT
- ICS
- IDE
- IIS
- Indy
- InnoSetup
- javascript
- jQuery
- JSON
- LiveBindings
- MSHTML
- MySQL
- PHP
- REST
- Ribbons
- SMS
- SQL инструкции
- SVN
- TRichView
- UniGui
- WebBroker
- WinAPI
- Windows
- Алгоритмы
- Без рубрики
- Деревья
- Ищу ответ
- Компонентостроение
- Мои компоненты
- Начальный уровень
- Обработка исключений
- Парсинг
- Потоки(Threads)
- Регулярные выражения
- Тестирование приложений
Category Archives: C#
C#. Inheritance Has-a relation
123
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace inheritance { class Program { static void Main(string[] args) { } } class Radio { public void Power(bool turnOn) { } } class Car { private Radio myradio = new Radio(); // inherited with has-a relation public void TurnOnRadio(bool OnOff) { myradio.Power(OnOff); } } } |
Posted in C#
Comments Off on C#. Inheritance Has-a relation
C#. Incapsulation
get / set incapsulation
|
1 2 3 4 5 6 7 8 |
class SomeClass{ private int id; // field public int GetID() { return id; } public void SetID(int IDValue) {/*someLogicHere;*/ id = IDValue; } } |
properties incapsulation
|
1 2 3 4 5 6 7 8 9 10 11 12 |
class SomeClass2 { private int id; // << field public int IDValue { // << property get { return id; } set { /*someLogicHere;*/ id = IDValue; } } } |
properties incapsulation with value word
|
1 2 3 4 5 6 7 8 9 10 11 12 |
class SomeClass3 { private int id; // << field public int IDValue { // << property get { return id; } set { /*someLogicHere;*/ id = value; } // << value is contextual here } } |
automatical properties
|
1 2 3 4 5 |
class SomeClass4 { private int id; // << field public int ID { get; set; } } |
also
|
1 2 3 4 5 |
class SomeClass4 { private int id; // << field public int ID { get; protected set; } // only for family of classes } |
if property has object – it must be initialized
|
1 2 3 4 5 6 7 8 9 10 |
class Car { } class SomeClass5 { private Car c; // << field public Car C { get; set; } // will create c with null reference! Must be created in constructor public SomeClass5() { c = new Car(); } public SomeClass5(Car c) { C = c; } } |
123
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace incapsulation { class Program { static void Main(string[] args) { SomeClass sc = new SomeClass(); sc.someMethod(); // << incapsulated } } class SomeClass { public string someField; public void someMethod() { Console.WriteLine("do something with someField"+someField); } } } |
Posted in C#
Comments Off on C#. Incapsulation
C#. Static
123
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication2 { static class Program { static void Main(string[] args) { // } } // static fields and methods class SomeClass { public static void someMethod() { } // public static double FsomeField = 1.01; // << correct setting of static field public SomeClass(double someField) { FsomeField = someField; // << not correct always will be setted } } // static constructor class SomeClass2 { static SomeClass2() { /* for setting static fields from external */ } } // static class static class SomeClass3 {/*only static participaants here*/} } |
Posted in C#
Comments Off on C#. Static
C#. Chained constructors with this directive
123
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConstructorsChain { class Program { static void Main(string[] args) { } } class Car { public int velocity; public string driverName; public Car() { } public Car(int speed):this(speed,"") { } // link to main constructor public Car(int speed="15", string name="defaultName") // << main constructor with default param values { // some business logic here if (speed > 10) { speed = 7; Console.WriteLine("Too much"); } velocity = speed; driverName = name; } } } |
Posted in C#
Comments Off on C#. Chained constructors with this directive
C#. This
123
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace This { class Program { static void Main(string[] args) { SomeClass sc = new SomeClass(); sc.SetSomeField("randomValue"); } } class SomeClass { public string someField; //public void SetSomeField(string someField) { someField = someField; } // << bad public void SetSomeField(string someField) { this.someField = someField; } // << good } } |
Posted in C#
Comments Off on C#. This
C#. Nullable types – for work with databases null types
Nullable types, works only with value types
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace NullableTypes { class Program { static void Main(string[] args) { int? i = dr.GetIntFromDataBase() ?? 100; // using of ?? like if/else int? i = dr.GetIntFromDataBase(); if (i.HasValue) { Console.WriteLine("ok,value={0}",i.Value); } else { Console.WriteLine("null"); } } } class DataBaseReader { int? nullableInt = 10; // also like Nullable<int> someNullableInt = 10; double? nullableDouble = 3.14; bool? nullableBool = null; // string? s = "oops"; // << only for value types //methods public int? GetIntFromDataBase() { return nullableInt; } public double? GetDoubleFromDataBase() { return nullableInt; } } } |
Posted in C#
Comments Off on C#. Nullable types – for work with databases null types
C#. SendObjsByValueByRef
123
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SendObjsByValueByRef { class Program { static void Main(string[] args) { } // will change age or some other property but not object static void SendAPerson(Person p) { p.personAge = 99; p = new Person("Nikki", 99); } // will change an object too static void SendAPersonByRef(ref Person p) { p.personAge = 99; p = new Person("Nikki", 99); } } class Person { public string personName; public int personAge; //constructors public Person(string name, int age) { personName = name; personAge = age; } public Person() { } public void Display() { Console.WriteLine("Name:{0},Age:{1}", personName, personAge); } } } |
Posted in C#
Comments Off on C#. SendObjsByValueByRef
С#.Struct
123
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Structures { class Program { static void Main(string[] args) { Point p1; p1.X= 1; p1.Y = 2; p1.Display(); Point p2 = new Point(); p2.X = 1; p2.Y = 2; p2.Display(); } struct Point { public int X; public int Y; public Point(int XPos, int YPos) { X = XPos; Y = YPos; } // constructor public void Inc() { X++;Y++; } public void Dec() { X--; Y--; } public void Display() { Console.WriteLine("X={0},Y={1}", X, Y); } } } } |
Posted in C#
Comments Off on С#.Struct
C#. Enums
123
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Enums { class Program { static void Main(string[] args) { SomeEnum e = SomeEnum.Contractor; Console.WriteLine("enumName="+e.ToString()+" enumValue="+(int)e); Console.ReadLine(); } enum SomeEnum // int by default { Manager, // 0 Grunt, // 1 Contractor, // 2 VicePresident // 3 } enum SomeEnum2 //int by default { Manager = 102, // 0 Grunt = 107, // 1 Contractor = 11, // 2 VicePresident = 123 // 3 } enum SomeEnum3 : byte //int by default { Manager = 102, // 0 Grunt, // 1 Contractor, // 2 VicePresident // 3 } } } |
Posted in C#
Comments Off on C#. Enums
C#. Arrays
123
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Arrays { class Program { static void Main(string[] args) { } void setSimpleArrays(){ //way1 int[] myInts = new int[3]; myInts[0]=0; myInts[1]=1; myInts[2]=2; //way2 int[] myInts2 = new int[] { 1, 2, 3 }; //way3 int[] myInts3 = new int[3] { 1, 2, 3 }; //way4 int[] myInts4 = { 1, 2, 3 }; string[] myStrings = new string[3]; myStrings[0] = "1"; myStrings[1] = "2"; myStrings[2] = "3"; } //set var arrays void setVarArrays() { var a = new[] { 1, 2, 3 }; } //array of one type objs object[] objArr = new object[] { "obj1", "obj2", "obj3" }; //array of different type objs Shape[] shapes = { new Triangle("Triangle"), new Hexagon("Hexagon"), new Circle("Circle") }; //multi arrays int[,] matrix = new int[7, 7]; void fillMatrix() { for (var i = 0; i < 7; i++) { for (var j = 0; j < 7; j++) { matrix[i,j]= i * j; } } } // jagged Arrays private static void jaggedArrays() { int[][] myJaggedArray = new int[5][]; for (var i = 0; i < myJaggedArray.Length; i++) { myJaggedArray[i] = new int[i + 7]; } for (int i = 0; i < 5; i++) { for (int j = 0; j < myJaggedArray[i].Length; j++) { Console.WriteLine(myJaggedArray[i][j]+" "); // Console.WriteLine(); } // Console.WriteLine(); } } //System.Array private static void SystemArrayExamples() { var a = new[] {1,2,3}; System.Array.Reverse(a); System.Array.Sort(a); var b = new[] {0}; a.CopyTo(b,1); } } } |
Posted in C#
Comments Off on C#. Arrays