当前位置: 首页>>代码示例>>C#>>正文


C# Int32类代码示例

本文整理汇总了C#中Int32的典型用法代码示例。如果您正苦于以下问题:C# Int32类的具体用法?C# Int32怎么用?C# Int32使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Int32类属于命名空间,在下文中一共展示了Int32类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Write

		public override void Write(Int32 val)
		{
			val = Utilities.SwapBytes(val);
			base.Write(val);

			if (AutoFlush) Flush();
		}
开发者ID:svarogg,项目名称:System.Drawing.PSD,代码行数:7,代码来源:BinaryReverseWriter.cs

示例2: OnSuggest

 private void OnSuggest(IPeerWireClient client, Int32 pieceIndex)
 {
     if (SuggestPiece != null)
     {
         SuggestPiece(client, pieceIndex);
     }
 }
开发者ID:HaKDMoDz,项目名称:eStd,代码行数:7,代码来源:FastExtensions.cs

示例3: FindSuffixes

        /// <summary>
        /// Find suffixes in the pattern.
        /// </summary>
        /// <param name="pattern">Pattern for search.</param>
        /// <returns>Suffix array.</returns>
        private static Int32[] FindSuffixes(String pattern)
        {
            Int32 f = 0, g;

            Int32 patternLength = pattern.Length;
            Int32[] suffixes = new Int32[pattern.Length + 1];

            suffixes[patternLength - 1] = patternLength;
            g = patternLength - 1;
            for (Int32 i = patternLength - 2; i >= 0; --i)
            {
                if (i > g && suffixes[i + patternLength - 1 - f] < i - g)
                {
                    suffixes[i] = suffixes[i + patternLength - 1 - f];
                }
                else
                {
                    if (i < g)
                    {
                        g = i;
                    }
                    
                    f = i;

                    while (g >= 0 && (pattern[g] == pattern[g + patternLength - 1 - f]))
                    {
                        --g;
                    }

                    suffixes[i] = f - g;
                }
            }

            return suffixes;
        }
开发者ID:gnikolaropoulos,项目名称:.Net-Labs,代码行数:40,代码来源:BoyerMoore.cs

示例4: BigEndian

        /// <summary>
        /// Converts a <see cref="Int32"/> to big endian notation.
        /// </summary>
        /// <param name="input">The <see cref="Int32"/> to convert.</param>
        /// <returns>The converted <see cref="Int32"/>.</returns>
        public static Int32 BigEndian(Int32 input)
        {
            if (!BitConverter.IsLittleEndian)
                return input;

            return Swap(input);
        }
开发者ID:neokamikai,项目名称:rolib,代码行数:12,代码来源:EndianConverter.cs

示例5: HexNumberToInt32

 private static Boolean HexNumberToInt32(ref NumberBuffer number, ref Int32 value)
 {
     UInt32 passedValue = 0;
     Boolean returnValue = HexNumberToUInt32(ref number, ref passedValue);
     value = (Int32)passedValue;
     return returnValue;
 }
开发者ID:nattress,项目名称:corert,代码行数:7,代码来源:FormatProvider.FormatAndParse.cs

示例6: VerifyInt32ImplicitCastToComplex

        private static void VerifyInt32ImplicitCastToComplex(Int32 value)
        {
            Complex c_cast = value;

            if (false == Support.VerifyRealImaginaryProperties(c_cast, value, 0.0))
            {
                Console.WriteLine("Int32ImplicitCast ({0})" + value);
                Assert.True(false, "Verification Failed");
            }
            else
            {
                if (value != Int32.MaxValue)
                {
                    Complex c_cast_plus = c_cast + 1;
                    if (false == Support.VerifyRealImaginaryProperties(c_cast_plus, value + 1, 0.0))
                    {
                        Console.WriteLine("PLuS + Int32ImplicitCast ({0})" + value);
                        Assert.True(false, "Verification Failed");
                    }
                }

                if (value != Int32.MinValue)
                {
                    Complex c_cast_minus = c_cast - 1;
                    if (false == Support.VerifyRealImaginaryProperties(c_cast_minus, value - 1, 0.0))
                    {
                        Console.WriteLine("Minus - Int32ImplicitCast + 1 ({0})" + value);
                        Assert.True(false, "Verification Failed");
                    }
                }
            }
        }
开发者ID:gitter-badger,项目名称:corefx,代码行数:32,代码来源:implicitExplicitCastOperators.cs

示例7: Distribute

 public static Money[] Distribute(this Money money,
     FractionReceivers fractionReceivers,
     RoundingPlaces roundingPlaces,
     Int32 count)
 {
     return new MoneyDistributor(money, fractionReceivers, roundingPlaces).Distribute(count);
 }
开发者ID:madhon,项目名称:money-type-for-the-clr,代码行数:7,代码来源:MoneyExtensions.cs

示例8: Enter

    public void Enter() {
        // If calling thread already owns the lock, increment recursion count and return
        Int32 threadId = Thread.CurrentThread.ManagedThreadId;
        if (threadId == m_owningThreadId) { m_recursion++; return; }

        // The calling thread doesn't own the lock, try to get it
        SpinWait spinwait = new SpinWait();
        for (Int32 spinCount = 0; spinCount < m_spincount; spinCount++) {
            // If the lock was free, this thread got it; set some state and return
            if (Interlocked.CompareExchange(ref m_waiters, 1, 0) == 0) goto GotLock;

            // Black magic: give other threads a chance to run
            // in hopes that the lock will be released
            spinwait.SpinOnce();
        }

        // Spinning is over and the lock was still not obtained, try one more time
        if (Interlocked.Increment(ref m_waiters) > 1) {
            // Still contention, this thread must wait
            m_waiterLock.WaitOne(); // Wait for the lock; performance hit
            // When this thread wakes, it owns the lock; set some state and return
        }

        GotLock:
        // When a thread gets the lock, we record its ID and
        // indicate that the thread owns the lock once
        m_owningThreadId = threadId; m_recursion = 1;
    }
开发者ID:ppatoria,项目名称:SoftwareDevelopment,代码行数:28,代码来源:SimpleHybridLock1.cs

示例9: Document

 public Document(
     Int16 _TypeId,
     Int64 _Serial,
     Int32 _SignedUser,
     DateTime _Date,
     Boolean _Printed,
     String _DocumentShortName,
     String _DocumentFullName,
     String _MedexDataTable,
     String _DocumentBody,
     String _DocumentHeader,
     Boolean _SetDeleted
     
     )
 {
     TypeId = _TypeId;
        Serial = _Serial;
        SignedUser = _SignedUser;
        Date = _Date;
        Printed = _Printed;
        DocumentShortName = _DocumentShortName;
        DocumentFullName = _DocumentFullName;
        MedexDataTable = _MedexDataTable;
        DocumentBody = _DocumentBody;
        DocumentHeader = _DocumentHeader;
        SetDeleted = _SetDeleted;
 }
开发者ID:oeai,项目名称:medx,代码行数:27,代码来源:Document.cs

示例10: WaitAsync

        public Task<bool> WaitAsync(Int32 duration, CancellationToken token)
        {
           VerboseLog("{0:000}|{1}|async wait requested", Thread.CurrentThread.Id, _id);

            CheckDisposed();
            token.ThrowIfCancellationRequested();

            if (_sem.TryAcquire())
            {
                VerboseLog("{0:000}|{1}|async wait immediate success", Thread.CurrentThread.Id,_id);
                return Task.FromResult(true);
            }
                

            if(duration == 0)
                return Task.FromResult(false);
            
            if (_asyncWaiters == null)
            {
                lock (this)
                {
                    if (_asyncWaiters == null)
                        _asyncWaiters = new ConcurrentLinkedQueue<AsyncWaiter>();
                }
            }

            AsyncWaiter waiter = new AsyncWaiter();
            TaskCompletionSource<bool> task = new TaskCompletionSource<bool>();
            
            waiter.Task = task;

            if (duration != -1)
            {
                waiter.CancelDelay = new CancellationTokenSource();
                waiter.Delay = Task.Delay(duration, waiter.CancelDelay.Token);
                waiter.Delay.ContinueWith(new ActionContinuation(() => TimeoutAsync(waiter)));
            }

            if (token != CancellationToken.None)
            {
                waiter.CancelRegistration = token.Register(() => CancelAsync(waiter));
            }
         
            _asyncWaiters.Add(waiter);

            VerboseLog("{0:000}|{1}|async wait enqued: {2:X}; {3}", Thread.CurrentThread.Id, _id, waiter.GetHashCode(), waiter.Task.Task.Id);

            if (_wasDisposed || token.IsCancellationRequested || waiter.Delay != null && waiter.Delay.IsCompleted)
            {
                // Mitigate the above race where a finishing condition occured
                // before where able to add our waiter to the waiters list.
                if (_asyncWaiters.Remove(waiter))
                {
                    CleanUpWaiter(waiter);
                }
            }

            return task.Task;
        }
开发者ID:sebastianhaba,项目名称:api,代码行数:59,代码来源:SemaphoreSlim.cs

示例11: AnnounceInfo

            public AnnounceInfo(IEnumerable<EndPoint> peers, Int32 a, Int32 b, Int32 c)
            {
                Peers = peers;

                WaitTime = a;
                Seeders = b;
                Leachers = c;
            }
开发者ID:HaKDMoDz,项目名称:eStd,代码行数:8,代码来源:BaseScraper.cs

示例12: Int32

        public static byte[] Int32(Int32 i, Endianness e = Endianness.Machine)
        {
            byte[] bytes = BitConverter.GetBytes(i);

            if (NeedsFlipping(e)) Array.Reverse(bytes);

            return bytes;
        }
开发者ID:HaKDMoDz,项目名称:eStd,代码行数:8,代码来源:Pack.cs

示例13: UInt32

        public static UInt32 UInt32(byte[] bytes, Int32 start, Endianness e = Endianness.Machine)
        {
            byte[] intBytes = Utils.GetBytes(bytes, start, 4);

            if (NeedsFlipping(e)) Array.Reverse(intBytes);

            return BitConverter.ToUInt32(intBytes, 0);
        }
开发者ID:alex-kir,项目名称:System.Net.Torrent,代码行数:8,代码来源:Unpack.cs

示例14: SetInt32

        public static void SetInt32(this Byte[] buffer, Int32 value, Int32 pos)
        {
            Byte[] copybuffer;

            copybuffer = BitConverter.GetBytes(value);
            Array.Reverse(copybuffer);
            Array.Copy(copybuffer, 0, buffer, pos, 4);
        }
开发者ID:ConstObject,项目名称:COD_MP,代码行数:8,代码来源:IW6MP.cs

示例15: RequestAdd

 public RpcHeader RequestAdd(Int32 a, Int32 b)
 {
     var packetId = Interlocked.Increment(ref globalPacketId);
     return w.Request(() => {
     w.Write(a);
     w.Write(b);
     }, length => new RpcHeader((int)MethodId.Add, (uint)packetId, length));
 }
开发者ID:hythof,项目名称:csharp,代码行数:8,代码来源:RpcGenerateRequest.cs


注:本文中的Int32类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。