string path = "C:\test";
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
var filePath = Path.Combine(path, "test.pdf");
//web projects
var binFolder = System.Web.Hosting.HostingEnvironment.MapPath("~/bin/testlala.pdf");
//console application
var binFolder = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
Regex
CNPJ: [RegularExpression(@"\d{2}.\d{3}.\d{3}/\d{4}-\d{2}|(\d{14})$",
ErrorMessage = "Format not allowed.")]
CPF: [RegularExpression(@"^((\d{3}).(\d{3}).(\d{3})-(\d{2}))*$",
ErrorMessage = "Format not allowed.")]
String join concatenate
string.Join("", word1);
Regex
only alphanumeric "^[a-zA-Z0-9_]*$"
^ : start of string
[ : beginning of character group
a-z : any lowercase letter
A-Z : any uppercase letter
0-9 : any digit
_ : underscore
] : end of character group
* : zero or more of the given characters
$ : end of string
Date
Full date: DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss")
var jaggedArray = new int[2][]; (Array of arrays, in this case has 2 arrays. (read as 2 arrays and not 2 rows)
var multiDimensional = new int[2,3]; (most used)
char
var c = (char)(97);
Bigger
var numberA = 5;
var numberB = 10;
Math.Max(numberA, numberB);
Linq
var lettersGrouped = (from p in s.ToList()
group p by p into g
select new{
Key = g.Key,
Numbers = g.Count()
}).ToList();
List of alphabetic:
var alphabetic = new int[26];
word = "caio";
foreach (char item in word)
{
alphabetic[item - 'a'] = alphabetic[item - 'a'] + 1;
}
How to debug on javascript on MVC
Using debugger;
Interviews:
var newString = "newString";
newString.Substring(0, newString.Length);
var newDictionary = new Dictionary<char,int>();
newDictionary.TryGetValue('', out int value);
//initiating with collector
new Dictionary<string, string>() { { "laa", "1" } };
InterviewQuestions
IL (intermediate language) -> c# -> IL -> machine language
JIT -> Compilation of IL, and converts to machine learning (he is the optimizer who selects the best compiler for the best machine language win8 winx64
CLR -> Responsible for the native conversion (it calls the JIT) and also the garbage collector (manage the unused memory)
managed code -> umbrella code, under the CLR. (Common Language Runtime)
GC -> Garbage collector cleans managed resources. Donst manage OUTSIDE CLR env (c++)
CTS -> Common type specification ensures the data type will be commonly typed. [Bunch of guideliness]
Stacks vs Heaps -> stacks primary datatype and heaps objects. They are both memory types.
Unboxing -> int x = (y)variable;
ArrayList vs array -> ArrayList is not strongly typed (important), and it has a dynamic size
Generic Collections? -> Works like ArrayList but strongly typed.
Threads vs TPL -> Threads processor affinity. TPL automatically tries to find the idle core and distribute it better.
Delegates:
https://www.youtube.com/watch?v=jQgwEsJISy0
1- Define a delegate
2- Define an event based on that delegate
3- Raise the event
Optional- Use EventHandler
4- delegate needs to be passed before the Trigger Method (my mistake)
5- the signature needs to be respected (the name doesn't need to be the same)
Clone
(int[])Array.Clone() -> Always cast before executing the .Clone();
Math.Abs
Absolute value
OrderBy
OrderBy -> quickSort O(nLogN) and worst case n"2
IComparable
path
string path = "C:\test"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); }
var filePath = Path.Combine(path, "test.pdf");
//web projects var binFolder = System.Web.Hosting.HostingEnvironment.MapPath("~/bin/testlala.pdf");
//console application var binFolder = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
Regex
CNPJ: [RegularExpression(@"\d{2}.\d{3}.\d{3}/\d{4}-\d{2}|(\d{14})$", ErrorMessage = "Format not allowed.")] CPF: [RegularExpression(@"^((\d{3}).(\d{3}).(\d{3})-(\d{2}))*$", ErrorMessage = "Format not allowed.")]
String join concatenate
string.Join("", word1);
Regex
only alphanumeric "^[a-zA-Z0-9_]*$"
Date
Full date: DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss")
Jagged Array vs Multidimensional
var jaggedArray = new int[2][]; (Array of arrays, in this case has 2 arrays. (read as 2 arrays and not 2 rows) var multiDimensional = new int[2,3]; (most used)
char
var c = (char)(97);
Bigger
var numberA = 5; var numberB = 10; Math.Max(numberA, numberB);
Linq
List of alphabetic:
How to debug on javascript on MVC
Using debugger;
Interviews:
var newString = "newString"; newString.Substring(0, newString.Length);
var newDictionary = new Dictionary<char,int>(); newDictionary.TryGetValue('', out int value);
//initiating with collector new Dictionary<string, string>() { { "laa", "1" } };
InterviewQuestions
JIT -> Compilation of IL, and converts to machine learning (he is the optimizer who selects the best compiler for the best machine language win8 winx64
CLR -> Responsible for the native conversion (it calls the JIT) and also the garbage collector (manage the unused memory) managed code -> umbrella code, under the CLR. (Common Language Runtime) GC -> Garbage collector cleans managed resources. Donst manage OUTSIDE CLR env (c++) CTS -> Common type specification ensures the data type will be commonly typed. [Bunch of guideliness] Stacks vs Heaps -> stacks primary datatype and heaps objects. They are both memory types. Unboxing -> int x = (y)variable; ArrayList vs array -> ArrayList is not strongly typed (important), and it has a dynamic size Generic Collections? -> Works like ArrayList but strongly typed. Threads vs TPL -> Threads processor affinity. TPL automatically tries to find the idle core and distribute it better.Delegates:
Clone
(int[])Array.Clone() -> Always cast before executing the .Clone();
Math.Abs
Absolute value
OrderBy
OrderBy -> quickSort O(nLogN) and worst case n"2 IComparable
Transaction
Reflection
System.Reflection; Type type = newPerson.GetType(); prop = type.GetProperty("Name"); var propertyGetByReflection = prop.GetValue(newPerson);
Threads
System.Threading; Thread newTread = new Thread(new ThreadStart(WorkThreadFunction));
FAQ
Difference between Thread and Task? (Thread worker, task is what needs to be done)
Custom fonts
@font-face { font-family: 'Open Sans'; src: url('fonts/OpenSans-VariableFont_wdth,wght.ttf'); }
Pointers & unsafe code