Click here to Skip to main content
15,884,099 members
Home / Discussions / C#
   

C#

 
GeneralRe: maximum number of methods supported in C# class Pin
vytheese2-Jul-07 5:10
professionalvytheese2-Jul-07 5:10 
GeneralRe: maximum number of methods supported in C# class Pin
leppie2-Jul-07 6:17
leppie2-Jul-07 6:17 
GeneralRe: maximum number of methods supported in C# class Pin
Ed.Poore2-Jul-07 6:16
Ed.Poore2-Jul-07 6:16 
GeneralRe: maximum number of methods supported in C# class Pin
leppie2-Jul-07 6:18
leppie2-Jul-07 6:18 
GeneralRe: maximum number of methods supported in C# class Pin
Ed.Poore2-Jul-07 6:28
Ed.Poore2-Jul-07 6:28 
JokeRe: maximum number of methods supported in C# class Pin
Luc Pattyn2-Jul-07 4:10
sitebuilderLuc Pattyn2-Jul-07 4:10 
GeneralRe: maximum number of methods supported in C# class Pin
vytheese2-Jul-07 5:20
professionalvytheese2-Jul-07 5:20 
AnswerMore than 5000... Pin
Sean Michael Murphy2-Jul-07 9:25
Sean Michael Murphy2-Jul-07 9:25 
I let this run for an hour to get to 5000 before I gave up. Someone with more CPU and physical RAM than I have should run it and see where it ends...

C#
using System;
using System.Collections.Generic;
using System.Text;
using System.CodeDom.Compiler;
   
namespace MethodCountLimitFinder {
   class Program {
      static void Main(string[] args) {
         Int32 methodCount = 1;
         Microsoft.CSharp.CSharpCodeProvider cscp = new Microsoft.CSharp.CSharpCodeProvider();
         ICodeCompiler icc = cscp.CreateCompiler();
   
         CompilerParameters cp = new CompilerParameters();
         cp.GenerateExecutable = false;
         cp.GenerateInMemory = true;
   
         CompilerResults cr = null;
         string pre = "using System;" + Environment.NewLine +
                  Environment.NewLine +
                  "namespace Tester {" + Environment.NewLine +
                  "   class Test {" + Environment.NewLine;
         string post = "   }" + Environment.NewLine +
                  "}";
         string inner = string.Empty;
   
         while (true) {
            inner += "      public Int32 Method" + methodCount.ToString() + "() {" + Environment.NewLine +
                     "         return 42;" + Environment.NewLine +
                     "      }" + Environment.NewLine;
   
            cr = icc.CompileAssemblyFromSource(cp, pre + inner + post);
   
            if (cr.Errors.Count > 0)
               break;
   
            methodCount++;
   
            if (methodCount % 10 == 0)
               System.Console.WriteLine(methodCount.ToString());
         }
   
         System.Console.WriteLine(methodCount);
      }
   }
}

Share and enjoy

Sean
GeneralRe: More than 5000... Pin
DavidNohejl2-Jul-07 9:36
DavidNohejl2-Jul-07 9:36 
GeneralRe: More than 5000... Pin
Martin#2-Jul-07 10:03
Martin#2-Jul-07 10:03 
GeneralRe: More than 5000... Pin
PIEBALDconsult2-Jul-07 11:56
mvePIEBALDconsult2-Jul-07 11:56 
GeneralRe: More than 5000... Pin
Sean Michael Murphy2-Jul-07 15:28
Sean Michael Murphy2-Jul-07 15:28 
GeneralRe: More than 5000... Pin
DavidNohejl2-Jul-07 21:54
DavidNohejl2-Jul-07 21:54 
GeneralRe: More than 5000... Pin
PIEBALDconsult3-Jul-07 7:14
mvePIEBALDconsult3-Jul-07 7:14 
GeneralRe: More than 5000... Pin
DavidNohejl3-Jul-07 7:41
DavidNohejl3-Jul-07 7:41 
GeneralRe: More than 100000... Pin
vytheese2-Jul-07 23:16
professionalvytheese2-Jul-07 23:16 
GeneralRe: More than 100000... Pin
Sean Michael Murphy3-Jul-07 5:01
Sean Michael Murphy3-Jul-07 5:01 
GeneralRe: More than 5000... Pin
PIEBALDconsult3-Jul-07 7:37
mvePIEBALDconsult3-Jul-07 7:37 
GeneralMore than 1000000 [modified] Pin
PIEBALDconsult3-Jul-07 11:50
mvePIEBALDconsult3-Jul-07 11:50 
GeneralRe: More than 5000... Pin
Sean Michael Murphy4-Jul-07 18:36
Sean Michael Murphy4-Jul-07 18:36 
QuestionError in calling a webservice Pin
ramdil2-Jul-07 3:15
ramdil2-Jul-07 3:15 
AnswerRe: Error in calling a webservice Pin
leppie2-Jul-07 3:58
leppie2-Jul-07 3:58 
AnswerRe: Error in calling a webservice Pin
Vasudevan Deepak Kumar2-Jul-07 4:53
Vasudevan Deepak Kumar2-Jul-07 4:53 
QuestionCan't focus TextBox on TabPage Pin
Tavbi2-Jul-07 3:01
Tavbi2-Jul-07 3:01 
AnswerRe: Can't focus TextBox on TabPage Pin
Luc Pattyn2-Jul-07 3:20
sitebuilderLuc Pattyn2-Jul-07 3:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.