Search results for query: *

  • Users: mp3909
  • Content: Threads
  • Order by date
  1. M

    reflection GetCustomAttributes

    Comment in the code below says it all using System; using System.Reflection; namespace Sample { public class Valid : Attribute { } public class Customer { #region Properties public string firstname { get; set; } public string lastname { get; set; }...
  2. M

    Struct vs Class

    Why is it I get an error in the below code saying auto implemented property must be fully assigned before control is returned to the caller public struct Customer { private int id; private string name; public Customer(int a, string b) {...
  3. M

    Function return type question

    In the below code which I got from the Internet, function has return type as IList<String> but the function actually returns studenList which is declared as var. So I am bit confused how that works? private static IList<String> FindAllStudentFromDatabase(string studentName) { var...
  4. M

    Why is division by zero not throwing exception

    As the title explains, I would have excepted an exception on this line float result = fn / (float)sn; if fn = 45 and sn = 0 Instead I get 8 as the answer.
  5. M

    StreamWriter path's format

    This code using System; using System.IO; class Program { public static void Main(string[] args) { try { Console.WriteLine("Enter first number"); int.TryParse(Console.ReadLine(), out int a); Console.WriteLine("Enter second number")...
  6. M

    less than operator not working correctly

    why does 13 get printed out in the code below? 13 is not less 13 so it should not be be printed out, right? using System; using System.Collections.Generic; delegate void FooDelagate(string xx); class Program { public static void Main() { List<int> L = new List<int>()...
  7. M

    fields/properties/object Initilisation

    public class Cat { // Auto-implemented properties. public int Age { get; set; } public string Name { get; set; } public Cat() { } public Cat(string name) { this.Name = name; //I do not see a field called Name declared } } Cat cat = new Cat {...
  8. M

    Implementation of GetEnumerator Method

    Below is an implementation of the GetEnumerator method: IEnumerator IEnumerable.GetEnumerator() { return (IEnumerator) GetEnumerator(); } public PeopleEnum GetEnumerator() { return new PeopleEnum(_people); } Here is another way I have seen the GetEnumerator method being...
  9. M

    return new vs return?

    public class List : IEnumerable { private object[] _objects; public List() { _objects = new object[100]; } public void Add(object obj) { _objects[_objects.Count] = obj; } public IEnumerator GetEnumerator() { return new...
  10. M

    Array declaration

    I am wondering why the following gives an error: public class Program { public static void Main(string[] args) { public int[] numbers = new int[5]; } }
  11. M

    Yield return

    Hi, 1). Just want to confirm, can you only use the "yield return" statement inside a method that is of the return type "IEnumerable"? 2). I read somewhere that arrays and lists are enumerables so does that mean I can use the "yield return" statement inside a method that returns an array? 3)...
  12. M

    What programming route to take to solve a particular problem

    Hi, I wanted to get people's opinion on which programming language should I use to solve the following task: We get 4 raw source files from this internal system in house system. They are saved in a specific directory as csv files containing loads of columns of data. I'm talking all the way up...
  13. M

    Question Trying to export data into csv file using stored procedure

    Can someone please help me with the error I am getting in the attached file.
  14. M

    Delegates

    So, I read up on delegates and I am still confused why do we need them in C#? I mean, what's the point of calling a method indirectly through the use of a delegate when you can call that same method directly? I am failing to understand the essence of delegates and was hoping someone can give me...
  15. M

    structs

    I just finished up reading on structs in C#. I still do not understand why it is not possible to initialise instance fields in a struct but it is possible to initialise static fields? To make my question clearer, why does this give an error: using System; namespace Sample { struct Animal...
  16. M

    Indexes

    Hi, After spending some time understanding indexes in Mircrosoft SQL Server, I have a few questions: I understand data retrieval (i.e. Select statement) is quicker in a clustered index than a non-clustered index. But is this only true if and only if the columns you would like to get back are...
  17. M

    Constructors - are they really necessary?

    Hi, So I just learnt a new concept in C#. That is, the set and get methods which allow us to set the value of private fields in our classes and to also retrieve their values. An example code is shown below. Since we can set the values using the set method as shown in the code below (i.e...
  18. M

    Storing Even Numbers in Array

    Hi, I have written a piece of code to attempt storing the first 3 even numbers into an array called EvenNumbers. Here is my code using System; namespace Sample { class Program { static void Main() { int[] EvenNumbers = new int[3]...
  19. M

    Cannot display the value of protected internal variable

    I have this code in Assembly1: using System; using sample; namespace ConsoleApp1 { class Test:Customers { public void Display() { Console.WriteLine(a); } } class Program { static void Main() { Test t = new...
  20. M

    Declaring a method that takes an array of any datetype?

    In the code below, I am asking the user to give the dimensions of a multidimensional array. The user is then told to enter the values for the array. I then want to display the contents of an array by passing it to a method called display. The question I have is that how can I make this method...
Back
Top Bottom