Interger Type problem

StreamWriter sw = File.CreateText(paraColumnFolder + paraColid + "-" + (intCurrentPage-1) + ".htm");

Why (intCurrentPage-1) becomes "21" instead of "1" when intCurrentPage is "2" in value and it is of integer type.




Answer this question

Interger Type problem

  • Mateusz Rajca

    Sorry Tom, but there does not seem to be any problem with the code.
    I have tried the following snippet and it works fine.
    It created a file "NAME-1.htm" in my C: drive.

    using System;
    using System.Collections.Generic;
    using System.Text;
    namespace ConsoleApplication1
    {
    class Program
    {
    static void Main(string[] args)
    {
    int intCurrentPage = 2;
    System.IO.
    StreamWriter sw = System.IO.File.CreateText("C:\\NAME" + "-" + (intCurrentPage - 1) + ".htm");
    }
    }
    }



  • LMSmith

    Nihal, thanks. It does work fine.

    After cheking I found that intCurrentPage has been self-added for 20 times before, therefore it becomes 21 instead of 1.



  • Interger Type problem