-
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#.Inner Exceptions
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 |
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MySpecialException { class Program { static void Main(string[] args) { try { SomeClass sc = new SomeClass(); sc.SomeMethod(); } catch (SomeSpecialException e) { try { // if something happens during file open FileStream fs = File.Open(@"C:\123.txt",FileMode.Open); } catch (Exception e2) { throw new SomeSpecialException(e.Message, e2, DateTime.Now); } } } } public class SomeClass { public void SomeMethod() { //code SomeSpecialException ex = new SomeSpecialException("123","123",DateTime.Now); ex.HelpLink = "someLink"; throw ex; //code } } //--- public class SomeSpecialException : ApplicationException { private string MessageDetails = String.Empty; public DateTime ErrorTimeStamp { get; set; } public string CauseOfError { get; set; } //... public SomeSpecialException(string message, string cause, DateTime time) :base(message) // sent to base class constructor { // MessageDetails = message; // << no need ErrorTimeStamp = time; CauseOfError = cause; } //overriding Message Property /* public override string Message { get { return string.Format("ErrorMessage:{0}", MessageDetails); } } */ } } |
Posted in C#
Comments Off on C#.Inner Exceptions
C#. Rethrow Exception
123
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
class Program { static void Main(string[] args) { try { SomeClass sc = new SomeClass(); sc.SomeMethod(); } catch (Exception e) { Console.WriteLine(e.Message); throw; // << rethrow next } } } |
Posted in C#
Comments Off on C#. Rethrow Exception
C#. SpecialExceptions
123 Way 1
|
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 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MySpecialException { class Program { static void Main(string[] args) { try { SomeClass sc = new SomeClass(); sc.SomeMethod(); } catch (SomeSpecialException e) { Console.WriteLine( e.Message+"\n\r"+ e.ErrorTimeStamp+ "\n\r"+ e.CauseOfError+ "\n\r" ); Console.ReadLine(); } } } public class SomeClass { public void SomeMethod() { //code SomeSpecialException ex = new SomeSpecialException("123","123",DateTime.Now); ex.HelpLink = "someLink"; throw ex; //code } } //--- public class SomeSpecialException : ApplicationException { private string MessageDetails = String.Empty; public DateTime ErrorTimeStamp { get; set; } public string CauseOfError { get; set; } //... public SomeSpecialException(string message,string cause, DateTime time) { MessageDetails = message; ErrorTimeStamp = time; CauseOfError = cause; } //overriding Message Property public override string Message { get { return string.Format("ErrorMessage:{0}", MessageDetails); } } } } |
Posted in C#
Comments Off on C#. SpecialExceptions
С#. General Exception
most general way – not concrete – just something happened
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
class Program { static void Main(string[] args) { try { SomeClass sc = new SomeClass(); sc.SomeMethod(); } catch { Console.WriteLine("Some Exception happened..."); } } } |
simple example – catching Exception e
|
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 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace generalException2 { class Program { static void Main(string[] args) { SomeClass sc = new SomeClass(); try { sc.test(); } catch (Exception e) { Console.WriteLine("Method:{0}", e.TargetSite); // method Console.WriteLine("message:{0}", e.Message); // message Console.WriteLine("source:{0}", e.Source); // source Console.ReadLine(); } } } class SomeClass { public void test() { //some code throw new Exception("some message"); //some code } } } |
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 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace generalException { class Program { static void Main(string[] args) { Car c = new Car("someName",20); try { for (int i = 0; i < 10; i++) { c.Accelerate(10); } } catch (Exception e) { Console.WriteLine("Method:{0}", e.TargetSite); // method Console.WriteLine("message:{0}", e.Message); // message Console.WriteLine("source:{0}", e.Source); // source Console.ReadLine(); } } } public class Car { public const int MaxSpeed = 100; public int CurrentSpeed { get; set; } private bool CarIsDead; public string DriverName { get; set; } // public Car() { } public Car(string name, int speed) { CurrentSpeed = speed; DriverName = name; } // public void Accelerate(int delta) { if (CarIsDead) { Console.WriteLine("Car is Dead"); } else { CurrentSpeed += delta; if (CurrentSpeed > MaxSpeed) { CarIsDead = true; CurrentSpeed = 0; throw new Exception(string.Format("Car drives too fast!")); // throw exception here } else Console.WriteLine("Ok"); } } } } |
Posted in C#
Comments Off on С#. General Exception
C#. Abstract
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 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Abstract { class Program { static void Main(string[] args) { Triangle t = new Triangle(); } } abstract class Shape{ abstract public void Draw(); public virtual void Draw2() {/*some code*/ } } class Triangle : Shape { public override void Draw() { Console.WriteLine("Draw Triangle"); } public new void Draw2() {/*some code*/ } // << will hide realization } } |
Posted in C#
Comments Off on C#. Abstract
C#. Virtual.Override
123
|
1 2 3 4 5 6 7 8 9 10 11 |
public class SomeBaseClass{ public virtual void someMethod() { } // << virtual here } public class AnotherClass:SomeBaseClass { public override void someMethod() { // << override here //some code base.someMethod(); //some code } } |
Posted in C#
Comments Off on C#. Virtual.Override
C#. Base Directive in Constructor
123
|
1 2 3 4 5 6 7 8 9 10 11 |
class Car { private int speed; // field public int Speed { get; set; } // property public Car(int speed) { Speed = speed; } } sealed class Van : Car { // last in family private string vanLabel; public string VanLabel { get; set; } public Van( int speed, string vanLabel):base(speed) { VanLabel = vanLabel; } } |
Posted in C#
Comments Off on C#. Base Directive in Constructor
С#. Constants and readOnly fields
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 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace constReadOnlyAndPartitial { class Program { public const double Pi = 3.14; public readonly double Pi2 = 3.14; public Program() { //Pi = 3.14; // not Ok in constructor Pi2 = 3.16; // Ok in constructor } static void Main(string[] args) { } } } |
Posted in C#
Comments Off on С#. Constants and readOnly fields
C#. Initialization of inserted objects – modern and traditional ways
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 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace initInsertedTypes { class Program { static void Main(string[] args) { // modern way Rectangle r = new Rectangle() // { TopLeft = new Point() { X = 10, Y = 10 }, BottomRight = new Point() { X = 100, Y = 100 } }; // traditional way - more code )) Rectangle r2 = new Rectangle(); Point p1 = new Point(); p1.X = 10; p1.Y = 10; r2.TopLeft = p1; } } class Point { public int X { get; set; } public int Y { get; set; } public Point() { } public Point(int x, int y) { X = x; Y = y; } } class Rectangle { private Point topLeft = new Point(); private Point bottomRight = new Point(); public Point TopLeft { get { return topLeft; } set { topLeft = value; } } public Point BottomRight { get { return bottomRight; } set { bottomRight = value; } } public void Display() { } } } |
Posted in C#
Comments Off on C#. Initialization of inserted objects – modern and traditional ways
С#. Ways of Object Initialization
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 ObjectInitializers { class Program { static void Main(string[] args) { Point p1 = new Point(); // #1 p1.X = 10; p1.Y = 10; Point p2 = new Point(10,10);// #2 Point p3 = new Point{ X = 10, Y = 10 }; // #3 } } class Point { public int X { get; set; } public int Y { get; set; } public Point() { } public Point(int x, int y) { X = x; Y = y; } public void Display() { /*display on console*/ } } } |
Posted in C#
Comments Off on С#. Ways of Object Initialization