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

2016/07/26

How to generate C# classes from xml in Visual Studio ?


  1. Copy xml to clipboard
  2. Open Visual Studio -> create class file -> remove class definition -> edit menu -> Paste special -> Paste XML As Classes
  3. Replace typeA[][] to List<TypeA>

2016/07/22

2016/05/09

How to add existing resource file to project in c# ?

1. Install Add-in for Visual Studio: File nesting 2. Add root file and designer file 3. Right click on slave file -> File nesting -> Nest item

How to add existing WinForm to poject in C# ?

1. Select project -> Right click -> Add -> Existing item.. -> select root file -> Add as link

2016/02/14

How to generate c# classes from xml ?

xsd is available in systems with .net installed.
Usually here: C:\Program Files (x86)\Microsoft SDKs\Windows\
fg. C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\x64\xsd.exe

D:\temp>xsd test.xml
D:\temp>xsd test.xsd /classes

Solution found here: http://stackoverflow.com/a/4203551

Sometimes you will have to change generated cs files fg change double dimension array type [][] to []

2016/02/11

Resharper shortcuts

Shortcut Meaning
ctrl + shift + v Recent clipboard items
alt+end | Ctrl + click on class, method -> derived symbols | Navigate -> Derived symbosl Show all object that inherit from class or override methods

2016/02/10

How to compare sql server databases structure and data ?


  1. Install SQL Server Data Tools component https://msdn.microsoft.com/en-us/library/hh272686(v=vs.103).aspx in your Visual Studio version. 
  2. Show Sql Server Object Explorer in Visual Studio - View -> SQL Server Object Explorer
  3. Connect to server where one of your db is maintained in SQL Server Object Explorer Window
  4. Right click on the database and choose "Schema compare.." or "Data comparison"

How to read \ write to windows registry in c# ?

Run application with administartor privilages.