Every Question..What does it mean? Why is this? How it works?
Microsoft .Net (pronounced dot (.) net) may be a package element that runs on the Windows software package.
.Net provides tools and libraries that change developers to form Windows package a lot of quicker and easier.
Microsoft describes it as:".Net is that the Microsoft internet Service strategy to attach data, people,
system and devices through software".I'm Choulla Naresh..!
Wednesday, February 15, 2017
Tuesday, February 14, 2017
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.
Solution:
https://www.google.com/settings/security/lesssecureapps... go to this link and turn on... njoy
disable browser back button
<script>
window.onload = function () {
if (typeof history.pushState === "function") {
history.pushState("jibberish", null, null);
window.onpopstate = function () {
history.pushState('newjibberish', null, null);
// Handle the back (or forward) buttons here
// Will NOT handle refresh, use onbeforeunload for this.
var url = '@Url.Content("~/Account/LogOff")';
$.ajax({
url: url,
cache: false
});
};
}
}
</script>
window.onload = function () {
if (typeof history.pushState === "function") {
history.pushState("jibberish", null, null);
window.onpopstate = function () {
history.pushState('newjibberish', null, null);
// Handle the back (or forward) buttons here
// Will NOT handle refresh, use onbeforeunload for this.
var url = '@Url.Content("~/Account/LogOff")';
$.ajax({
url: url,
cache: false
});
};
}
}
</script>
Difference between Virtual Path, Absolute Path, Relative path And Physical Path
Virtual Path
To create a web app in IIS we can place our folder containing application in C:\inetpub\wwwroot or we can point to a location where the application is, like D:\MyApp. When we point an app to another location, then we specify this path. So the app in IIS is pointing to this virtual path.
Absolute Path
When we refer to a location from root like C:\Documents\MyFolder, it is absolute path.
Relative path
When we refer to a location relative where we currently are, it is called relative path. For example, say currently you are at Documents folder in C:\Documents, to refer to MyFolder you have two choices: Absolute (C:\Documents\MyFolder) or relative (\MyFolder).
Physical Path
In ASP.NET physical path refers to the absolute path in terms of windows. In web applications we refer to the web path, which for a web application starts from "/" (root) which is the folder that contains the application. But that root folder must be in IIS, so the path like C:\inetpub\wwwroot\myapp is the physical path.
Difference between int,int16,int32,int64 C#
A number of developers think that int represents a 32-bit integer when the application is running on a 32-bit OS and it represents a 64-bit integer when the application is running on a 64-bit OS. This is absolutely wrong.
In C# int is a primitive data type and it always mapped to System.Int32 whether the OS is 32-bit or 64-bit.
int
It is a primitive data type defined in C#.
It is mapped to Int32 of FCL type.
It is a value type and represent System.Int32 struct.
It is signed and takes 32 bits.
It has minimum -2147483648 and maximum +2147483647 capacity.
Int16
It is a FCL type.
In C#, short is mapped to Int16.
It is a value type and represent System.Int16 struct.
It is signed and takes 16 bits.
It has minimum -32768 and maximum +32767 capacity.
Int32
It is a FCL type.
In C#, int is mapped to Int32.
It is a value type and represent System.Int32 struct.
It is signed and takes 32 bits.
It has minimum -2147483648 and maximum +2147483647 capacity.
Int64
It is a FCL type.
In C#, long is mapped to Int64.
It is a value type and represent System.Int64 struct.
It is signed and takes 64 bits.
It has minimum –9,223,372,036,854,775,808 and maximum 9,223,372,036,854,775,807 capacity
In C# int is a primitive data type and it always mapped to System.Int32 whether the OS is 32-bit or 64-bit.
int
It is a primitive data type defined in C#.
It is mapped to Int32 of FCL type.
It is a value type and represent System.Int32 struct.
It is signed and takes 32 bits.
It has minimum -2147483648 and maximum +2147483647 capacity.
Int16
It is a FCL type.
In C#, short is mapped to Int16.
It is a value type and represent System.Int16 struct.
It is signed and takes 16 bits.
It has minimum -32768 and maximum +32767 capacity.
Int32
It is a FCL type.
In C#, int is mapped to Int32.
It is a value type and represent System.Int32 struct.
It is signed and takes 32 bits.
It has minimum -2147483648 and maximum +2147483647 capacity.
Int64
It is a FCL type.
In C#, long is mapped to Int64.
It is a value type and represent System.Int64 struct.
It is signed and takes 64 bits.
It has minimum –9,223,372,036,854,775,808 and maximum 9,223,372,036,854,775,807 capacity
Generate Model property from database
use c08824
--from SO: http://stackoverflow.com/questions/5873170/generate-class-from-database-table
declare @TableName sysname = '[CMCT].[Checks]' -- table name
declare @Result varchar(max) = 'public class ' + @TableName + '
{'
select @Result = @Result + '
public ' + ColumnType + NullableSign + ' ' + ColumnName + ' { get; set; }
'
from
(
select
replace(col.name, ' ', '_') ColumnName,
column_id ColumnId,
case typ.name
when 'bigint' then 'long'
when 'binary' then 'byte[]'
when 'bit' then 'bool'
when 'char' then 'string'
when 'date' then 'DateTime'
when 'datetime' then 'DateTime'
when 'datetime2' then 'DateTime'
when 'datetimeoffset' then 'DateTimeOffset'
when 'decimal' then 'decimal'
when 'float' then 'float'
when 'image' then 'byte[]'
when 'int' then 'int'
when 'money' then 'decimal'
when 'nchar' then 'char'
when 'ntext' then 'string'
when 'numeric' then 'decimal'
when 'nvarchar' then 'string'
when 'real' then 'double'
when 'smalldatetime' then 'DateTime'
when 'smallint' then 'short'
when 'smallmoney' then 'decimal'
when 'text' then 'string'
when 'time' then 'TimeSpan'
when 'timestamp' then 'DateTime'
when 'tinyint' then 'byte'
when 'uniqueidentifier' then 'Guid'
when 'varbinary' then 'byte[]'
when 'varchar' then 'string'
else 'UNKNOWN_' + typ.name
end ColumnType,
case
when col.is_nullable = 1 and typ.name in ('bigint', 'bit', 'date', 'datetime', 'datetime2', 'datetimeoffset', 'decimal', 'float', 'int', 'money', 'numeric', 'real', 'smalldatetime', 'smallint', 'smallmoney', 'time', 'tinyint', 'uniqueidentifier')
then '?'
else ''
end NullableSign
from sys.columns col
join sys.types typ on
col.system_type_id = typ.system_type_id AND col.user_type_id = typ.user_type_id
where object_id = object_id(@TableName)
) t
order by ColumnId
set @Result = @Result + '
}'
print @Result
--from SO: http://stackoverflow.com/questions/5873170/generate-class-from-database-table
declare @TableName sysname = '[CMCT].[Checks]' -- table name
declare @Result varchar(max) = 'public class ' + @TableName + '
{'
select @Result = @Result + '
public ' + ColumnType + NullableSign + ' ' + ColumnName + ' { get; set; }
'
from
(
select
replace(col.name, ' ', '_') ColumnName,
column_id ColumnId,
case typ.name
when 'bigint' then 'long'
when 'binary' then 'byte[]'
when 'bit' then 'bool'
when 'char' then 'string'
when 'date' then 'DateTime'
when 'datetime' then 'DateTime'
when 'datetime2' then 'DateTime'
when 'datetimeoffset' then 'DateTimeOffset'
when 'decimal' then 'decimal'
when 'float' then 'float'
when 'image' then 'byte[]'
when 'int' then 'int'
when 'money' then 'decimal'
when 'nchar' then 'char'
when 'ntext' then 'string'
when 'numeric' then 'decimal'
when 'nvarchar' then 'string'
when 'real' then 'double'
when 'smalldatetime' then 'DateTime'
when 'smallint' then 'short'
when 'smallmoney' then 'decimal'
when 'text' then 'string'
when 'time' then 'TimeSpan'
when 'timestamp' then 'DateTime'
when 'tinyint' then 'byte'
when 'uniqueidentifier' then 'Guid'
when 'varbinary' then 'byte[]'
when 'varchar' then 'string'
else 'UNKNOWN_' + typ.name
end ColumnType,
case
when col.is_nullable = 1 and typ.name in ('bigint', 'bit', 'date', 'datetime', 'datetime2', 'datetimeoffset', 'decimal', 'float', 'int', 'money', 'numeric', 'real', 'smalldatetime', 'smallint', 'smallmoney', 'time', 'tinyint', 'uniqueidentifier')
then '?'
else ''
end NullableSign
from sys.columns col
join sys.types typ on
col.system_type_id = typ.system_type_id AND col.user_type_id = typ.user_type_id
where object_id = object_id(@TableName)
) t
order by ColumnId
set @Result = @Result + '
}'
print @Result
Friday, February 3, 2017
what is the use of partial class in C#
A partial class splits the definition of a class over two or more source files. You can create a class definition in multiple files but it will be compiled as one class.
More than one developer can simultaneously write the code for the class.
Suppose you have a "Emp" class. That definition is divided into the two source files "Emp1.cs" and "Emp2.cs". Then these two files have a class that is a partial class. You compile the source code, then create a single class.
Or Suppose you have a class that has multiple interfaces so you can create multiple source files depending on interface implements. It is easy to understand and maintain an interface implemented on which the source file has a partial class.
More than one developer can simultaneously write the code for the class.
Suppose you have a "Emp" class. That definition is divided into the two source files "Emp1.cs" and "Emp2.cs". Then these two files have a class that is a partial class. You compile the source code, then create a single class.
Or Suppose you have a class that has multiple interfaces so you can create multiple source files depending on interface implements. It is easy to understand and maintain an interface implemented on which the source file has a partial class.
Saturday, January 7, 2017
What is the use of static variable in C#? When to use it? Why can't I declare the static variable inside method?
A static variable shares the value of it among all instances of the class.
Example without declaring it static
public class Variable
{
public int i = 5;
public void test()
{
i=i+5;
Console.WriteLine(i);
}
}
public class Exercise
{
static void Main()
{
Variable var = new Variable();
var.test();
Variable var1 = new Variable();
var1.test();
Console.ReadKey();
}
}
Explanation:If you look at the above example i just declare int variable.when i run this code the output will be 10 and 10.Its simple
Now Lets Look at the static variable Here,I am declaring the variable as a static.
Example with static variable
public class Variable
{
public static int i = 5;
public void test()
{
i=i+5;
Console.WriteLine(i);
}
}
public class Exercise
{
static void Main()
{
Variable var = new Variable();
var.test();
Variable var1 = new Variable();
var1.test();
Console.ReadKey();
}
}
Now when I run above code then the output will be 10 and 15. So static variable value is shared among all instances of that class.
Example without declaring it static
public class Variable
{
public int i = 5;
public void test()
{
i=i+5;
Console.WriteLine(i);
}
}
public class Exercise
{
static void Main()
{
Variable var = new Variable();
var.test();
Variable var1 = new Variable();
var1.test();
Console.ReadKey();
}
}
Explanation:If you look at the above example i just declare int variable.when i run this code the output will be 10 and 10.Its simple
Now Lets Look at the static variable Here,I am declaring the variable as a static.
Example with static variable
public class Variable
{
public static int i = 5;
public void test()
{
i=i+5;
Console.WriteLine(i);
}
}
public class Exercise
{
static void Main()
{
Variable var = new Variable();
var.test();
Variable var1 = new Variable();
var1.test();
Console.ReadKey();
}
}
Now when I run above code then the output will be 10 and 15. So static variable value is shared among all instances of that class.
Friday, December 16, 2016
Access denied fix for whatismyipaddress.com
//Rextester.Program.Main is the entry point for your code. Don't change it.
//Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5
using System;
using System.IO;
using System.Net;
using System.Text;
namespace Rextester
{
public class Program
{
public static void Main(string[] args)
{
// Create a request for the URL.
WebRequest request = WebRequest.Create (
//@"http://whatismyipaddress.com/ip/31.207.0.99"
"http://ipv4bot.whatismyipaddress.com"
);
// If required by the server, set the credentials.
// Get the response.
WebResponse response = request.GetResponse ();
// Display the status.
Console.WriteLine (((HttpWebResponse)response).StatusDescription);
// Get the stream containing content returned by the server.
Stream dataStream = response.GetResponseStream ();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader (dataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd ();
// Display the content.
Console.WriteLine (responseFromServer);
// Clean up the streams and the response.
reader.Close ();
response.Close ();
}
}
}
//Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5
using System;
using System.IO;
using System.Net;
using System.Text;
namespace Rextester
{
public class Program
{
public static void Main(string[] args)
{
// Create a request for the URL.
WebRequest request = WebRequest.Create (
//@"http://whatismyipaddress.com/ip/31.207.0.99"
"http://ipv4bot.whatismyipaddress.com"
);
// If required by the server, set the credentials.
// Get the response.
WebResponse response = request.GetResponse ();
// Display the status.
Console.WriteLine (((HttpWebResponse)response).StatusDescription);
// Get the stream containing content returned by the server.
Stream dataStream = response.GetResponseStream ();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader (dataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd ();
// Display the content.
Console.WriteLine (responseFromServer);
// Clean up the streams and the response.
reader.Close ();
response.Close ();
}
}
}
Subscribe to:
Posts (Atom)