Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

Sunday, August 19, 2018

How do you change the default language for installed templates in Visual Studio Community 2017?

You may find that after you launch the Visual Studio you may not see some of the templates that you were using previously. This is especially true after you install a new version or an upgrade. However you can correct this and is not a bug. I got the answer to this from Visual Studio Forum.

Here is how it started when it was launched after a version upgrade. I upgraded the version to Version 15.8.0.


Aug15_1580_0.png

Click Tools and click Import and Export Settings... shown.


Aug15_1580_1.png

The Import and Export Settings Wizard is displayed as shown.


Aug15_1580_2.png

I just took the default(first option on the above page) and clicked next>
Choose Settings to Export of the wizard is shown.


Aug15_1580_3.png

Click Next>

Name Your settings File page of wizard is displayed as shown.


Aug15_1580_4.png

I clicked Finish and my settings were saved.


Aug15_1580_5.png

When I launched Visual Studio nothing had changed. I still got the Visual Basic templates.

I went back to Import and Export to do a Reset All Settings as shown.


Aug15_1580_6.png

And then, I saved my settings in the next window.


Aug15_1580_7.png

I chose Visual C# for Default Collection of Settings in the following window


Aug15_1580_8.png

I clicked Finish to complete the Reset as shown. I disregarded the error.



Aug15_1580_9.png

I closed the above window and lanuched Visual Studio and clicked the Fiel | New Project...
Now I could see the C# templates as shown.


Aug15_1580_10.png





Sunday, August 12, 2018

Is the Visual Studio Community 2017 version 15.7.6 better than 15.7.5?

It was noticed while using Visual Studio 2017 Version 15.7.5 that C# templates were not found in their usual local in the New Project... window. This absence was raised in one of the Forums post and it was triaged by the Forum monitor.

Please review the following posts regarding this issue:

http://hodentekhelp.blogspot.com/2018/07/why-are-c-templates-missing-in-visual.html

http://hodentekhelp.blogspot.com/2018/07/why-are-c-templates-missing-in-visual_31.html

https://developercommunity.visualstudio.com/content/problem/301590/c-templates-are-mssing.html

As far as the unavailability of C# templates 15.7.6 is no better than its earlier version.

Since the version 15.7.5  did not work for C#, it was decided to try the next version, 15.7.6. This was available and it was installed  using the Visual Studio Community 2017 version 15.7.5.


Although C# templates were not found in their usual location they were available in the Other Languages node as shown.


A Blank App (UWP) project was created as shown.

An unhandled exception was thrown as seen above. The build process came up with some warnings but no errors.


The Deploy in Build menu item did not throw any errors and was deployed. There is a corresponding shortcut to the app in the All Programs.


However trying to run the app on the LocalMachine came up with this message.


The version 15.7.6 has the same problem as the 15.7.5 or something very nearly the same problem.


Thursday, August 9, 2018

What programming language do you want to learn?


Of course, you want the most popular and the most valuable.

According to the Institute of Electrical and Electronics Engineers (IEEE) , it is Python, the clear winner.

Here are the top ten in its rankings:


Why Python?

The answer appears to the fact that it iss now used for embedded applications and because it has beefed up its repertoire related to AI and Machine learning. It is for this reason R language (somewhat specialized) has seen some decline.

Microsoft C# is still standing there at 5 and probably its place will be solid 5 for all types of programming - Web, desktop and Mobile. SQL is also there but does not show up as top 10 which is understandable given its area of usage.

Well here is the first 20. Find if your favorite is here



Well, you may want to know the basis for the ranking. You can get to know here.

You can find a lot of posts on R and Python on this site.



You can find a lot of Python and R posts in my blogs.

Wednesday, August 8, 2018

How do programming languages calculate PI approximations?


Two very well known approximations to PI are 22/7 (West) and 355/113 (Chinese).


As numbers how are they treated in Python, C#, SQL Server and the desktop 'Calculator' app?

It was fun looking into this. Here are how they work.

Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 10:22:32) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> x=(355/113)
>>> x
3.1415929203539825
>>> y=(22/7)
>>> y
3.142857142857143
>>> x-y
-0.0012642225031602727
>>> y-x
0.0012642225031602727
>>>
----------------
Desktop Calculator

355/113=3.141592920353982
22/7=   3.142857142857143
PI=3.1415926535897932384626433832795
----------------

SQL Server 2017
Select cast((22.0000000000/7.0000000000) as numeric(30,25))
3.1428571428571428571428000

Select cast((355.0000000000/113.0000000000) as numeric(30,25))
3.1415929203539823008849550
-------------------------
C# Interactive in Visual Studio Community 2017
double y;
> y = 22 / 7;
> y
3
> y = 22.0000000000 / 7.0000000000;
> y
3.1428571428571428
> double x;
> x = 355 / 113;--delete this line
> x = 355.0000000000 / 113.0000000000;
> x
3.1415929203539825
>
I like the way Python spitted out the answer with lot less things to worry about.  Also, desktop calculator not to bad. What do you think?

Friday, July 13, 2018

What is Dynamic Language Runtime (DLR)?

Dynamic Language Runtime(DLR) is a runtime environment that adds set of services for dynamic languages to the Common Language Runtime.

The difference between dynamic languages and statically typed languages such as C# and Visual Basic is that you need to specify the object type at design time for the latter.

There are a lot of popular dynamic languages such as the following:

LISP
SmallTalk
Javascript
PHP
Ruby
Python
ColdFusion, Lua
Cobra and
Groovy

Dynamic languages are also excellent scripting languages used in designing Web sites; data transformations; artificial intelligence, etc.

The main driver for DLR is to create the ability to run the dynamic languages on top of the CLR. Dynamic objects (in System.dynamic) now can be used in C# and Visual Basic. This in Visual studio Community 2017.


DLR_0
Here is the architecture of DLR for IronPython and IronRuby from Microsoft documentation in MSDN.


DLR.png

Tuesday, May 8, 2018

How do you use Interactive Python in Visual Studio 2017 Community?

Visual Studio provides access to Interactive C#, Python and F#. We have already seen how to use C# interacitve in visual Studio.

Herein, we will start Python Interactive in Visual Studio 2017 Community IDE.

Launch Visual Studio 2017 Community from All Programs (look under V).


PythonInterA_0.png


Click Start and in the start Window click View | Other Windows as shown. You will see all interactive programs that you can use in Visual Studio.


PythonInterA_1.png

Click Python Interactive. Python 3.7 (x32) opens as shown.


PythonInterA_2.png

Enter some simple calculation to start with and note that intellisense-type feature is available as long as the DB is current.

PythonInterA_3.png


You can see the result as shown.

PythonInterA_4.png

$help command opens the help file and keyboard shortcuts as shown.



PythonInterA_5.png
That is all...

Saturday, April 28, 2018

What is the most popular programming language presently?

Looking back at my previous post on programming language popularity C language was at the top with Java in the second place.


However according to a chart on this site  shown here, Java continues to be the king once in a while ceding the top place.


TiobeIndex2017.png

Note that Python is rising, probably because of its use in AI, BigData and Robotics.

Tuesday, March 27, 2018

How do you convert Integer to Boolean in C#?


Start Interactive C# in Visual Studio Community 2017. Here are examples of integers (+ and -) and 0 converted to Boolean, using the Convert.ToBoolean(). This functions has 8 overloads.

Read here about running C# in interactive mode.

> bool p = Convert.ToBoolean(6);
> p
true
> bool k = Convert.ToBoolean(0);
> k
false
> bool q = Convert.ToBoolean(-8);
> q
true



Thursday, February 15, 2018

How to write a SWITCH statement in a UWP project?

SWITCH is a selection statement that selects a switch section among a number of switch sections based on a pattern match with the switch expression.


Switch.png

The default need not be the last case section, as it is evaluated last, no matter where it is found.
In the case constant (case sensitive).
  • constant is the value to test for, and it can be any of the following:
  • A bool literal, either true or false.
  • Any integral constant, such as an int, a long, or a byte. 
  • The name of a declared const variable.
  • An enumeration constant.
  • A char literal.
  • A string literal.
The following is a complete example in a UWP project called JSwitch:

In this example, the variable anim is set to 'bird'. It is case sensitive. Bird is not the same as bird. When the switch statement is run and it finds 'bird' in any of the case sections, it displays the corresponding case constant in the text box. Change 'anim' and run the app again, and the textbox displays the match.

The XAML page has just one TEXTBOX and a BUTTON. The button click runs the program MainPage.xaml.cs.

Here is the MainPage.xaml for the JSwitch project.


Here is the MainPage.xaml.cs code:



Wednesday, December 20, 2017

How do you create apps for SQL Server

This is a very useful site that you should acquaint yourself with. You can create apps that work with SQL Server with all of the following:

C#
Java
NodeJS
PHP
Python

on

Windows
macOS
RHEL
UBUNTU
SLES (Suse...)



You need to start at this link:

Tuesday, September 12, 2017

What is Microsoft Universal Windows Platform (UWP) App?

UWP is an app for the Windows 10 and Windows 10 runs on a number of hardware devices: PC, tablet, Xbox, HoloLens, Surface Hub etc. UWP with just one API set and one app package and one store can reach all screen sizes from the smallest to the largest.

It can support different modes of interaction;
touch
mouse + key board
pen
game controller

Programming UWP apps is very flexible, just not limited to C# and XAML. You can use JavaScript(& HTML). You could also use Unity or MonoGame. You can mix them as well.

You will create just one project for (any) every device you want to address.

Let me enumerate the features:
  • Common API surface across all devices
  • Extension SDKs to do specific stuff on chosen device
  • Apps packaged using .AppX packaging format and distributed from store
  • One store for all devices
  • Adaptive controls and input are supported(Keyword Responsive design)
Go on, monetize your app!

Sunday, November 8, 2015

How do you open a C# compiler prompt in Windows 10?


I assume you have installed Visual Studio 2015 Community. If this is correct, when you installed Visual Studio 2015 Community you also installed VS 2015 x86 Native Tools command prompt. This will be in your Program Files(x86) directory. Just double click this and type in CSC at command prompt as shown:


Compiler0.png

You can type in the command for help and get all the related information:

Please note the next two screen shots are for yet another version of the compiler(an earlier version)

Continued

What is SQL CLR or SQLCLR?

In order to understand what is SQLCLR, you need to know what the individual parts, Sequential Query Language (SQL) and Common Language Runtime (CLR) are.

Common Language Runtime is the programming that manages the execution of programs written in any of the supported languages such as C#, VB, Visual C++ etc to share common object orineted classes. Thiss is somewhat like Java Virtual Machine for programs run from Java. CLR is also called 'managed execution environment'. CLR is therefore related to .NET programming.

SQL is a language that is needed to run queries (post questions to) against SQL Server databases. It is not specific to Microsoft SQL Server. It can also be used with other databases like Oracle, Sybase, etc.
However Transact SQL (T-SQL) is the enhancement to add some progrmmability to SQL.
SQL Common Language Runtime (SQLCLR) is the combo technology (SQL Server and .NET) for hosting .NET common language runtime engine within SQL Server. In other words you can run managed code from within SQL Server.

Since T-SQL already adds to SQL the programming capability why does one need SQL CLR?

The reason I that there are certain useful class of programs that are just not handled by T-SQL, or make it much more complex and less secure. Of course there are more reasons why SQL CLR is needed. This is the reason for the development of SQL CLR. Also Microsoft made extensive integration of SQL Server with its massive .NET programming which makes it lot more flexible.

For, Creating a Visual C++ CLR Console Application in Visual Studio 2015 go here.

Thursday, January 29, 2015

How popular is JavaScript?

It has gained lot of popularity because of the many libraries developed such as jQuery, Bootstrap, Node.JS, Win.JS, dojo etc. Together with HTML5 it has become all the more popular for web development.

The popularity of a programming language is described by an index called the TIOBE Index.
TIOBE index provides a measure for the popularity of programming languages as mined from search engines. It includes many browser results as well as many programming languages. The index is published every month and for the month of January you can find it here:
http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html

Programming languages C and Java are the top dogs and Javascript jumped from 9 to 7 in January 2015 and C# steady from 2014 to 2015 at 5.

TIOBE Index is calculated by the query +"Language> programming" to the search engines.

Get more info on TIOBE herre:
http://www.tiobe.com/index.php/content/products/tics/TICS_framework.html

Tuesday, January 27, 2015

Where do I find the C# Compiler on my computer?


The C# compiler CSC.exe is found here:
  C:\Windows\Microsoft.NET\Framework\v4.0.30319\Csc.exe

This is on a Windows 8.1 Professional machine.

In any case search in this folder by changing the directory as shown below
C:/ cd %Windir%/Microsoft.NET/Framework

You may find more than one Framework on your computer
The one shown in the beginning of this post is for version 4.0.30319

Monday, January 26, 2015

Can I work on Stored Procedures using LinqPad?

Of course you can. In LinqPad version 4.51.03 you can easily run stored procedures you have created using both SQL and C# Expression.

For example, after connecting to AdvventureWorks2012 database I can see all the stored procedures. Right clicking a stored procedure and choosing StoredProceedureName(...) drop-down, you display the stored procedure in the query window. You need to insert the parameters inside the parenthesis containing the ellipsis and run the query.

Examples are shown in the following two posts:

http://hodentekmsss.blogspot.com/2015/01/learn-querying-sql-server-2012-using.html

http://hodentekmsss.blogspot.com/2015/01/learn-querying-sql-server-2012-using_25.html

Sunday, December 7, 2014

What is LINQ?

We know that a query is a question we pose to the database to retrieve some information that we would like to know. For example, in a database that consists of men and women, you may want to know how many men and how many women. Let us go a step further and say that there are people of all nationalities in the database of men and women. You may want to know how many women who hail from Europe are there. This is only filtering of the information but a query can much more complex. This is of course querying a database, let us say a relational database such as the SQL Server where you use the Structured Query Language(SQL), a special language you have to learn.

All data are not in relational databases and they could be in some kind of an XML document, a web service or something else. For example, in order to find some filtered content in an XML document you would use a language called XQuery which is not the same as SQL. This means there is need to learn another query language.

Beginning with Visual Studio 2008 and .NET Framework 3.5 Microsoft introduced LINQ which stands for Language-Integrated Query an innovation that made it possible to query a SQL Server database, an XML document, Web Services etc with a single lanugage and it is a first class query language.

In Visual Studio you can write LINQ in both VB and C# for any collection that supports IEnumerable or the generic IEnumerable interface (or to put it simply a collection in which one can go through the collection item by item).

For example you may have a list  of names ("John", "Tom", "June", "Diana") etc.  or  the number of rows in a database table , etc. and they can be queried using LINQ.

Need to query SQL Server with LinqPad, review the following posts:

http://hodentekmsss.blogspot.com/2014/12/learn-querying-sql-server-using-linq.html
http://hodentekmsss.blogspot.com/2014/12/learn-querying-sql-server-2012-using.html

Wednesday, September 18, 2013

What languages can I use to build Windows Store Apps?

There are a couple of options. The language you use will depend on your familiarity with the language. Here is the list.

1.Javascript/HTML(CSS)
2. C#/XAML
3. Visual Basic/XAML
4. C++/XAML
5. C++/DirectX